MVC Forms LoginUrl is incorrect

前端 未结 8 881
旧时难觅i
旧时难觅i 2020-11-30 07:07

I have an ASP.NET MVC 3 application with forms authentication. For some reason that I cannot see, the login redirect url is /Account/Login?ReturnUrl=%2fSecure%2fAction

相关标签:
8条回答
  • 2020-11-30 08:11

    Instead of this:

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

    You could use this:

    <appSettings>
      <add key="PreserveLoginUrl" value="true" />
    </appSettings>
    

    It worked for me.

    0 讨论(0)
  • 2020-11-30 08:13

    frennky's answer helped me get to this. I needed all of these in my web.config:

    <appSettings>
      <add key="loginUrl" value="~/Authentication/LogOn" />
    </appSettings>
    
    <system.web>
      <authentication mode="Forms">
        <forms loginUrl="~/Authentication/LogOn" timeout="2880"></forms>
       </authentication>
       <authorization>
         <deny users="?"/>
       </authorization>
    </system.web>
    
    0 讨论(0)
提交回复
热议问题