Infinite Loop in Query String In MVC Project – Yellow Screen Of Death

When you set up your MVC project with Windows Authentication, e.g.


...
  
...

You are likely to encounter the yellow screen of death with the following error message when running your solution on the internal Visual Studio IIS Express:

HTTP Error 404.15 – Not Found The request filtering module is configured to deny a request where the query string is too long.

If you look the query string, you’ll notice that it looks like the code is hitting an infinite loop trying to authenticate and redirecting to the URL plus the return URL, then doing it again and so on and so on.

Now, one way to fix this is, a rather obvious one, to disable Windows Authentication and enable Anonymous Authentication. In order to do that, select your MVC project in the Solution Explorer and hit F4 to see the properties (note that these are different from those in the context menu). Then set Windows Authentication property to false and Anonymous Authentication property to true. By doing so, however, you’re losing the ability to use the user principal, which is sort of important if you needed Windows Authentication in the first place.

So what you are really looking for is to disable OWIN startup class discovery in web.config:


    

Put that in there and viola! Problem solved and still have access to the user principal!

This entry was posted in MVC and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *