正在诊断登录重定向循环
本文关键字:重定向 循环 登录 诊断 | 更新日期: 2023-09-27 18:25:32
我的ISP最近在我的网站上遇到了几个权限问题,我的网站托管在一个共享的IIS盒子上。
我的MVC5应用程序在默认页面上没有需要身份验证的代码,但有一些区域可以进行
我已经将我的应用程序Web发布到了一个子目录"test"中,当我尝试加载任何[AllowAnonymous]页面时,我目前正在获得一个无限重定向循环,结果会得到404。
http://www.mywebsite.co.uk/test/Account/Login?ReturnUrl=%2Ftest%2FAccount%2FLogin%3FReturnUrl%3D%252Ftest%252FAccount%252FLogin%253FReturnUrl%253D%25252Ftest%25252FAccount%25252FLogin%25253FReturnUrl%25253D%2525252Ftest%2525252FAccount%2525252FLogin%2525253FReturnUrl%2525253D%252525252Ftest%252525252FAccount%252525252FLogin%252525253FReturnUrl%252525253D%25252525252Ftest%25252525252FAccount%25252525252FLogin%25252525253FReturnUrl%25252525253D%2525252525252Ftest%2525252525252FAccount%2525252525252FLogin%2525252525253FReturnUrl%2525252525253D%252525252525252Ftest%252525252525252FAccount%252525252525252FLogin%252525252525253FReturnUrl%252525252525253D%25252525252525252Ftest%25252525252525252FAccount%25252525252525252FLogin%25252525252525253FReturnUrl%25252525252525253D%2525252525252525252Ftest%2525252525252525252FAccount%2525252525252525252FLogin%2525252525252525253FReturnUrl%2525252525252525253D%252525252525252525252Ftest%252525252525252525252FAccount%252525252525252525252FLogin%252525252525252525253FReturnUrl%252525252525252525253D%25252525252525252525252Ftest%25252525252525252525252FAccount%25252525252525252525252FLogin%25252525252525252525253FReturnUrl%25252525252525252525253D%2525252525252525252525252Ftest%2525252525252525252525252FAccount%2525252525252525252525252FLogin%2525252525252525252525253FReturnUrl%2525252525252525252525253D%252525252525252525252525252Ftest%252525252525252525252525252FAccount%252525252525252525252525252FLogin%252525252525252525252525253FReturnUrl%252525252525252525252525253D%25252525252525252525252525252Ftest%25252525252525252525252525252FAccount%25252525252525252525252525252FLogin%25252525252525252525252525253FReturnUrl%25252525252525252525252525253D%2525252525252525252525252525252Ftest%2525252525252525252525252525252FAccount%2525252525252525252525252525252FLogin%2525252525252525252525252525253FReturnUrl%2525252525252525252525252525253D%252525252525252525252525252525252Ftest%252525252525252525252525252525252FAccount%252525252525252525252525252525252FLogin%252525252525252525252525252525253FReturnUrl%252525252525252525252525252525253D%25252525252525252525252525252525252Ftest%25252525252525252525252525252525252Fhome%25252525252525252525252525252525252Ffeedback
(我认为这个404是查询字符串太长的结果)
如果我将"相同"的代码发布到test2,则不会出现此问题。
我试着从_layout.cshtml中删除项目,看看我是否能发现是什么调用导致了这种情况,但在剥离所有项目后,我仍然会出现这个错误。
有人对我可以用来诊断问题所在有什么建议吗?
通常这就是问题所在,登录页面不允许未经授权的用户:你会得到无尽的循环-未经授权用户不允许看到登录页面,所以他被重定向到登录页面以获得授权。
因此,在控制器中的登录操作上需要[AllowAnonymous]
属性,或者添加到web.config:
<location path="/test/account/login">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>