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?

3
  • Could you provide any more information? What was it set to when it was working? What has changed since then? Commented Jun 23, 2011 at 1: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. Commented Jun 23, 2011 at 2: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? Commented Jun 23, 2011 at 9:20

2 Answers 2

37

Try adding this to appSettings in your web.config:

<add key="loginUrl" value="~/Account/LogOn" />
Sign up to request clarification or add additional context in comments.

6 Comments

Thank you. Why is this? It seems odd that the other method doesn't work.
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.
Still seems to be an issue in MVC4. Thanks frennky!
+1 But when are they going fix this??
Seems to be broken on webforms and framework 4.0 This saved my bacon. Thanks
|
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.

1 Comment

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".

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.