Reputation: 336
I've created a MVC Web Application using Visual Studio 2015. My goal is to change the authentication mode from none to Windows Authentication as I need so I can use the @User.Identity.Name method to identify the user. A short summary of what I've tried so far:
<authentication mode="Windows"/>
within the <system.web>
tagadding the system.webServer tag (this ends up in a ERR_TOO_MANY_REDIRECTS whenever I add it):
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxUrl="10999" maxQueryString="2097151" />
</requestFiltering>
</security>
</system.webServer>
I tried creating a new project from scratch and neatly selecting Windows Authentication during the setup of the project. This works fine, so I believe my IISExpress settings are 100% correct. I even checked the applicationhost.config file and it doesn't have an entry for my specific project. Again, it works just fine if I select the correct authentication when creating a new project.
None of the above seems to work and all end up with an IIS error when I try to run the Visual Studio project:
HTTP Error 404.15 - Not Found
The request filtering module is configured to deny a request where the query string is too long.
This is what the URL looks like in the IIS Error Page:
As you can tell I get an infinite redirect loop, and this is probably the reason why I'm unable to get this working. I do however have no idea what is causing it. Any help is greatly appreciated.
Upvotes: 4
Views: 2160
Reputation: 336
Guess I'm able to answer my own question as I've just got it working. Might come in handy for people who experience similar errors in the future.
Solution: I had to comment out the following code in App_Start/Startup.Auth.cs:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
Upvotes: 9
Reputation: 103
You could also check C:\Users[Your UserName]\Documents\IISExpress\Logs[Application Name] for any error details or URL used during request.
Upvotes: 1