asp.net mvc3, Authorize attribute redirects to wro

2019-07-28 04:04发布

问题:

I have a page that needs to be secured. I add [Authorize] attribute to that action method. if you are not logged in, you will be redirect to the login page everytime you visit that secure page.

it works except I rename logon action to login , but applicaiton still redirects user to logon action. its no long there, I rename it, how do I fix it?

回答1:

In your Web.config file change the forms loginUrl.

<authentication mode="Forms">
  <forms loginUrl="~/Controller/Action" />
</authentication>


回答2:

You need to set the loginUrl in the <forms /> element in Web.config.