I have an MVC3 website set up with only Windows Authentication enabled (so anonymous and forms are disabled). Whenever I try to hit the default page, something forwards me to this URL;
.../MyApp/Account/Login?ReturnUrl=%2fMyApp%2f
And I get an error;
The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /MyApp/Account/Login
There's nothing in my web.config which is configured to look for this URL, but there was a section about using forms authentication which I removed;
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
Should I have reconfigured this setting instead of removing it outright? I tried adding this in;
<authentication mode="Windows"></authentication>
But it still forwards back to the same place. Is there anything extra I should be doing here?
When you enable Windows authentication, your web server becomes responsible for authenticating users. Typically, there are two different types of web servers that you use when creating and deploying an ASP.NET MVC application.
By default MVC apps use Form Authentication and Simple Membership, so you need to make it "false" to run Windows Authentication. Select the project name in Solution Explorer and then in the Property Explorer, click to enable Windows Authentication.
On the taskbar, click Start, and then click Control Panel. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off. Expand Internet Information Services, then World Wide Web Services, then Security. Select Windows Authentication, and then click OK.
OK, so I came across the following article: http://martinnormark.com/asp-net-mvc-3-windows-authentication-problem-redirects-to-account-login
And from that, I added the following keys to my web.config in the app settings section:
<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>
And that solved my issue - Windows Authentication now works as expected, and there are no more redirects to a login page that doesn't exist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With