开发者

Difference in Forms Authentication between Razor Preview and Razor Beta?

开发者 https://www.devze.com 2023-01-20 16:41 出处:网络
I\'m attempting to upgrade an MVC project to Beta using Razor (from the Preview release) and am now experiencing strangeness with Razor not going to my login view that it use to开发者_如何学JAVA go to

I'm attempting to upgrade an MVC project to Beta using Razor (from the Preview release) and am now experiencing strangeness with Razor not going to my login view that it use to开发者_如何学JAVA go to (when someone asks for an action that required authorization).

My web config has

  <authentication mode="Forms">
    <forms loginUrl="~/Account/LogOn" timeout="2880" />
  </authentication>

But whenever an action with the Authorize attribute is hit, the browser redirects to "Account/Login" - notice Log*in* NOT Log*On*. Anyone know how to fix this in MVC 3 Beta?


It is a known bug in Beta: Release Notes: Chapter Known Issues

There’s a known issue that causes Forms Authentication to always redirect unauthenticated users to /Account/Login, ignoring the forms authentication setting used in Web.config. The workaround is to add the following app setting.

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


Try adding the following the <configuration> section of your application's Web.config file:

<appSettings>
  <add key="enableSimpleMembership" value="false" />
</appSettings>


All you need is to disable the authentication mode="Forms".

I removed the authentication section and it started to work.

<!--
 <authentication mode="Forms">
    <forms loginUrl="~/Account/LogOn" timeout="2880" />
  </authentication>
-->
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号