1
我正在擴大Web應用程序的安全性。 (會話/會員cookie到期確切)。當我嘗試在認證之前導航到頁面時,我注意到一些奇怪的事情。該頁面在登錄時起作用,當我嘗試在登錄之前轉到該頁面時,我將其重定向到登錄頁面(正常),但接下來我發送的位置不正確。它似乎缺少網址中的區域。我想知道這是否與路線有關?登錄MVC中的ReturnURL
下面是一些更多的信息:
從web.config中代碼:
<authentication mode="Forms">
<forms loginUrl="~/logininformation/loginhomepage" timeout="2880" />
</authentication>
- 原始地址:
mysite.com/Display/Page/Index/62
- URL重定向後登錄:登錄後
mysite.com/logininformation/loginhomepage?ReturnUrl=%2fPage%2fIndex%2f62
- 網址:
mysite.com/Page/Index/62
代碼:
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}