14

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?

tereško
  • 58,060
  • 25
  • 98
  • 150
Chris McAtackney
  • 5,192
  • 8
  • 45
  • 69
  • This fixed it for me.. http://stackoverflow.com/questions/28483745/http-error-404-15-not-found-because-the-query-string-is-too-long – Shovers_ Jan 04 '17 at 11:04

3 Answers3

19

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.

Community
  • 1
  • 1
Chris McAtackney
  • 5,192
  • 8
  • 45
  • 69
4

When we saw this before; it was related to this auth issue but not solved by any of the solutions

Forms auth redirecting css/script includes to the login page with HTTP 302

Our problem was there was simply an extra folder with dlls copied to the bin dir that should not have been included in the deploy. Manually deleting the bin & obj directories and rebuilding the web app after that cleared it up for us.

Community
  • 1
  • 1
Dave Lawrence
  • 3,843
  • 2
  • 21
  • 35
2

Check if you have references to WebMatrix.Data.dll and WebMatrix.WebData.dll files and try removing their references.

And if you've added references via Add Deployable Dependencies, also remove from _bin_deployableAssemblies folder.

Mehmet Osmanoglu
  • 1,212
  • 15
  • 22