ASP.NET MVC Beta Authorize attribute sends me to wrong action

痞子三分冷 提交于 2019-12-01 15:47:36

ScottGu replies to a similar question on his blog that this is apparently a bug.

The workaround is to add this entry:

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

to your <appSettings/> section in the web application's root web.config file.

It doesn't work with the RTM any more

You need to add

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

to the appSettings in the Web.Config

The issues is in ConfigUtil in WebMatrix.WebData

private static string GetLoginUrl()
{

    return ConfigurationManager.AppSettings[FormsAuthenticationSettings.LoginUrlKey] ?? FormsAuthenticationSettings.DefaultLoginUrl;
}



staticFormsAuthenticationSettings()
{
    LoginUrlKey = "loginUrl";
    DefaultLoginUrl = "~/Account/Login";
}

After I delete WebMatrix*.dll in bin directory, everything is OK.

Farjad

MVC 4 exhibits the same problem. However on MVC 4 if authentication mode is correctly set to ="Forms" in the configuration file, like in the following, the problem disappears:

<authentication mode ="Forms">
    <forms loginurl = "your login" timeout ="2880" slidingExpiration="true">
</authentication>

It works for me. Take out the mode and it gives you trouble.

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