FormsAuthentication LoginUrl

11,922

Try adding this to appSettings in your web.config:

<add key="loginUrl" value="~/Account/LogOn" />
Share:
11,922

Related videos on Youtube

Kyeotic
Author by

Kyeotic

I am a software developer living in Hillsboro, OR. I primarily use Javascript, I used to work with C#. If you want to contact my email is tim[at]kye[dot].dev I am also the author of Mastering KnockoutJS. https://kye.dev I used to be "Tyrsius"

Updated on June 01, 2022

Comments

  • Kyeotic
    Kyeotic almost 2 years

    I am at a total loss here. This was working earlier. I have an MVC3 app using forms authentication. In web config, I have the following:

    <authentication mode="Forms">
      <forms loginUrl="~/Login/Index" timeout="2880"/>
    </authentication>
    

    Yet, for some reason, when redirecting, or when checking FormsAuthentication.LoginUrl, its still using the default /Account/Login. Which doesn't exists. Why isnt the web.config overriding this?

  • Kyeotic
    Kyeotic almost 13 years
    Thank you. Why is this? It seems odd that the other method doesn't work.
  • frennky
    frennky almost 13 years
    I cannot remember where I found this on the net, but there is mention of it in release notes for MVC3 under section known issues.
  • Dan F
    Dan F over 11 years
    Still seems to be an issue in MVC4. Thanks frennky!
  • 79E09796
    79E09796 almost 11 years
    +1 But when are they going fix this??
  • SWalters
    SWalters over 10 years
    For anyone else who has come across this: WebMatrix 'takes over' the URL for forms authentication, as explained here; you can preserve your intended login routing by adding an appsetting - key="PreserveLoginUrl" value="true".