17

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?

frennky
  • 12,581
  • 10
  • 47
  • 63
Kyeotic
  • 19,697
  • 10
  • 71
  • 128
  • Could you provide any more information? What was it set to when it was working? What has changed since then? – dkarzon Jun 23 '11 at 01:27
  • It was set to the same thing when it was working. A dozen changes were made, the app is still being heavily worked on. None of the changes should have affected this though. I'm trying to find out though were else the value of formsauthentication.loginurl is set, since its not taking its value from the web.config. – Kyeotic Jun 23 '11 at 02:23
  • @Tyrsuis - check Fiddler, to see a mystery redirect is happening. Then check action filters, global filters, global asax, etc to see is some code is hijacking the redirect. Did you check web.config.debug and web.config.release? – RPM1984 Jun 23 '11 at 09:20

2 Answers2

37

Try adding this to appSettings in your web.config:

<add key="loginUrl" value="~/Account/LogOn" />
frennky
  • 12,581
  • 10
  • 47
  • 63
0

I have also had these issues and it only happened when i had added deployable assemblies and webmatrix.dll was added. That is when it started to try to redirect to an Account Controller which was not specified anywhere in my project.

Once i removed webmatrix.dll everything worked as intended.

Kimpo
  • 5,835
  • 4
  • 26
  • 30
  • 2
    For anyone else who has come across this: WebMatrix 'takes over' the URL for forms authentication, as explained [here](http://stackoverflow.com/questions/13321843/what-is-the-preserveloginurl-appsetting-key-value-in-an-asp-net-mvc-application); you can preserve your intended login routing by adding an appsetting - key="PreserveLoginUrl" value="true". – SWalters Aug 20 '13 at 01:46