Automatic redirection of FormsAuthentication to other URL than specified in the Web.Config?

泪湿孤枕 提交于 2019-12-14 02:05:33

问题


I have this section in the Web.config for my MVC3 application:

<authentication mode="Forms">
  <forms loginUrl="~/Account/LogOn" timeout="20" slidingExpiration="true"/>
</authentication>

Until recently every time the code hit an [Authorize] attribute the LogOn.cshtml page was shown. All of a sudden the redirection takes place to Account/Login (not the 'i' instead of the 'O'!!!) and I get a resource not found exception. I did a Find on the Web.config and could not find the word 'login' anywhere! What on Earh can have gone wrong?


回答1:


This is a known issue with ASP.NET MVC 3 as stated in the release notes. To solve it simply add the following to the <appSettings> node of your web.config:

<appSettings>
    <add key="loginUrl" value="~/Account/LogOn" />
<appSettings>

or try with the following key as suggested by the release notes:

<add key="autoFormsAuthentication" value="false" />


来源:https://stackoverflow.com/questions/7220191/automatic-redirection-of-formsauthentication-to-other-url-than-specified-in-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!