Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC website forwards to /Account/Login with only Windows Authentication enabled

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?

like image 343
Chris McAtackney Avatar asked Sep 03 '12 07:09

Chris McAtackney


People also ask

How does Windows Authentication work in MVC?

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.

How do I add Windows Authentication to an existing MVC project?

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.

How do I change Windows Authentication in web config?

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.


1 Answers

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.

like image 161
Chris McAtackney Avatar answered Sep 19 '22 16:09

Chris McAtackney