Cool Breeze
Cool Breeze

Reputation: 1369

Custom Errors in ASP.net MVC6

I have created an ASP.net 5 MVC6 project and added the following:

  app.UseStatusCodePages();

inside my Configure method. If I run the application, open my web browser and navigate to the following URL:

http://localhost:33358/ReallyLongInvalidPathReallyLongInvalidPathReallyLongInvalidPathReallyLongInvalidPathReallyLongInvalidPathReallyLongInvalidPathReallyLongInvalidPathReallyLongInvalidPath

ASP Displays a 404 error message which is the expected behavior. If I navigate to an even longer invalid URL such as:

http://localhost:33358/EvenLongerInvalidPathEvenLongerInvalidPathEvenLongerInvalidPathEvenLongerInvalidPathEvenLongerInvalidPathEvenLongerInvalidPathEvenLongerInvalidPathEvenLongerInvalidPathEvenLongerInvalidPathEvenLongerInvalidPathEvenLongerInvalidPathEvenLongerInvalidPathEvenLongerInvalidPath

I now get the following:

Bad Request - Invalid URL

If you navigate to the equivalent MSDN URL you get the same result. However If you navigate to the equivalent stackoverflow URL it is somehow handled. How are they handling this? and how can this be done in ASP.net MVC6?

Upvotes: 0

Views: 461

Answers (1)

Pratik
Pratik

Reputation: 888

Are you getting a 404.15 ? it might be that the query string length is too long for IIS . Check this https://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits

Try changing the maxQueryString attribute in thr requestLimits section in web.config to see if it helps.

Upvotes: 0

Related Questions