Cool Breeze
Cool Breeze

Reputation: 1369

404.20 Exception not being caught by ASP.net Core

I have created a new 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:34741/invalidroute 

I am presented with a: Status Code: 404; Not Found error. This is expected, however if I make the route more complicated for example:

 http://localhost:34741/this/is/a/complicated/route/this/is/a/complicated/route/this/is/a/complicated/route/this/is/a/complicated/route/this/is/a/complicated/route/this/is/a/complicated/route/this/is/a/complicated/route/

I am presented with a HTTP Error 404.20 - Not Found IIS Detailed Error page. Why is this no longer being handled by asp?

I have tried playing around with httpErrors in my web.config file and I have also tried setting a default document in IIS but I can't get a custom error page working :(

Upvotes: 1

Views: 2141

Answers (2)

Naveed Zafar
Naveed Zafar

Reputation: 51

maxurlSegments Settings need to be changed in IIS, good thing is that setting can be changed for individual site or Server Level

Upvotes: 0

Lex Li
Lex Li

Reputation: 63142

https://support.microsoft.com/en-us/kb/943891

404.20 comes from IIS. There is a setting "maxurlSegments" to control how many segments are allowed, which you can find in

https://www.iis.net/configreference/system.applicationhost/sites/site/limits

Modify that IIS setting and the error should go away.

Upvotes: 3

Related Questions