asp.net mvc3, Authorize attribute redirects to wrong login page

纵然是瞬间 提交于 2019-12-11 13:37:44

问题


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.



来源:https://stackoverflow.com/questions/8751500/asp-net-mvc3-authorize-attribute-redirects-to-wrong-login-page

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