2013-02-14 57 views
0

我希望有人能夠解釋一下如何解決我遇到的ReturnUrl問題。我有我的默認網站下運行的ASP.NET MVC 4 Web應用程序,一切看起來罰款...的RETURNURL指向一個基本控制器上的搜索行動:當應用程序作爲虛擬目錄託管在一個站點下時,ASP.NET MVC ReturnUrl混淆了

http://localhost/Login/Index?ReturnUrl=%2fBasic%2fSearch 

如果我提出這個申請到另一臺機器,並在虛擬目錄部署它,我得到一個不同的RETURNURL:

http://localhost2/virtualdirectory/Login/Index?ReturnUrl=%2fvirtualdirectory%2fBasic%2fSearch 

現在的「virtualdirectory」在RETURNURL正顯示出,當然它正確不路由。

在我的web.config,我已經配置如下:

<authentication mode="Forms"> 
    <forms loginUrl="~/Login/Index" timeout="2880" /> 
</authentication> 

任何幫助或建議,將不勝感激。

+0

所以基本上當它重定向它重定向到:http:// localhost2/virtualdirectory/BasicSearch看起來應該工作?登錄後什麼是重定向網址? – Victor 2013-02-14 02:45:38

+0

@Victor網址是:localhost2/virtualdirectory/virtualdirectory/Basic/Search我們正在努力獲取localhost2/virtualdirectory /基本/搜索 – 2013-02-14 14:33:13

+0

@ RichardO'Neil您是否曾經找到過解決方案? – Rob 2013-07-08 04:39:42

回答

0

這取決於你如何做重定向。如果你像這樣重定向,它應該可以工作:

[HttpPost] 
public ActionResult LogOn(LogOnModel model, string returnUrl) 
{ 
    //... omitted some preliminary validation ... 
    return Redirect(returnUrl); 
} 

我們正在使用這種設置,它適用於虛擬目錄。

相關問題