[英]ASP.NET FormsAuthentication won't redirect to Default.aspx in root
I've got forms authentication setup as follows: 我有如下形式的身份验证设置:
Web.config: Web.config文件:
<authentication mode="Forms">
<forms slidingExpiration="true" cookieless="UseCookies" timeout="180" loginUrl="Login.aspx" defaultUrl="Default.aspx" name=".ASPXVEWPAUTH"/>
</authentication>
<authorization>
<deny users="?" />
</authorization>
Login.aspx: Login.aspx:
/**Auth logic in button click**/
FormsAuthentication.RedirectFromLoginPage(username, false);
The Login.aspx and Default.aspx pages both live in the root of the application. Login.aspx和Default.aspx页面都位于应用程序的根目录中。
Every time I login it redirects me back to the login page. 每次登录时,它都会将我重定向回登录页面。 If I just go straight to Default.aspx, it redirects me to the login page as it should, puts Default.aspx into the returnUrl query string as it should, then when I login it redirects me back to Login.aspx with no query string.
如果我直接进入Default.aspx,它将按照需要将我重定向到登录页面,将Default.aspx放入应有的returnUrl查询字符串中,然后在我登录时将其重定向到没有查询字符串的Login.aspx 。 If I try to login again, with no query string, it still just goes back to Login.aspx.
如果尝试不使用查询字符串再次登录,它仍然会返回到Login.aspx。
If I change defaultUrl to a page outside of the root, it redirects fine, no problem. 如果我将defaultUrl更改为根目录之外的页面,它将重定向很好,没有问题。
If I change FormsAuthentication.RedirectFromLoginPage(username, false);
如果我更改
FormsAuthentication.RedirectFromLoginPage(username, false);
to just Response.Redirect("Default.aspx");
只是
Response.Redirect("Default.aspx");
, the redirect still doesn't work. ,重定向仍然无效。
If I change <deny users="?" />
如果我更改
<deny users="?" />
<deny users="?" />
to <allow users="?" />
<deny users="?" />
到<allow users="?" />
<allow users="?" />
, I can load Default.aspx just fine by going directly to it, but the redirect still doesn't work. <allow users="?" />
,我可以直接直接加载Default.aspx,但是重定向仍然不起作用。
I'm at a complete loss here. 我在这里完全不知所措。 I've never seen this behaviour before and I'm out of ideas to try.
我以前从未见过这种行为,并且没有尝试的想法。 Why won't it let me redirect to a page inside the root of the application?
为什么不让我重定向到应用程序根目录内的页面? Any help is greatly appreciated.
任何帮助是极大的赞赏。
Turns out it was an IIS Express problem. 原来这是一个IIS Express问题。 I tried running it on my local IIS and it worked fine.
我尝试在本地IIS上运行它,但效果很好。 I reinstalled IIS express and it also seems to work fine now.
我重新安装了IIS express,现在看来也可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.