FormsAuthentication LoginUrl
11,922
Try adding this to appSettings
in your web.config
:
<add key="loginUrl" value="~/Account/LogOn" />
Related videos on Youtube
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, 2022Comments
-
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 almost 13 yearsThank you. Why is this? It seems odd that the other method doesn't work.
-
frennky almost 13 yearsI 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 over 11 yearsStill seems to be an issue in MVC4. Thanks frennky!
-
79E09796 almost 11 years+1 But when are they going fix this??
-
SWalters over 10 yearsFor 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".