404.20 Exception not being caught by ASP.net Core

…衆ロ難τιáo~ 提交于 2019-12-11 12:46:22

问题


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 :(


回答1:


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.



来源:https://stackoverflow.com/questions/35126535/404-20-exception-not-being-caught-by-asp-net-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!