47

I was reviewing some ASP.NET MVC code, specifically a web.config file.

I noticed this in the appSettings section:

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

  1. What does this do?
  2. When was it introduced to ASP.NET MVC?

cheers!

1 Answer 1

44

From the MVC 4 Whitepaper:

When WebMatrix.WebData.dll is included in in the /bin directory of an ASP.NET MVC 4 apps, it takes over the URL for forms authentication. Adding the WebMatrix.WebData.dll assembly to your application (for example, by selecting "ASP.NET Web Pages with Razor Syntax" when using the Add Deployable Dependencies dialog) will override the authentication login redirect to /account/logon rather than /account/login as expected by the default ASP.NET MVC Account Controller. To prevent this behavior and use the URL specified already in the authentication section of web.config, you can add an appSetting called PreserveLoginUrl and set it to true

Sign up to request clarification or add additional context in comments.

4 Comments

Cheers! and why would we want the WebMatrix.WebData.dll in our /bin directory?
I think that's for when you create a Web Pages application using WebMatrix, or when you add Web Pages as Deployable Dependency in an MVC project. I don't know why the setting gets included for a default MVC app. The assembly contains membership and security classes that can also be used in MVC.
Is it relevant for MVC5 apps? Thanks
in .net core template, is this setting available?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.