404.20异常不被ASP.net核心抓 [英] 404.20 Exception not being caught by ASP.net Core

查看:273
本文介绍了404.20异常不被ASP.net核心抓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的ASP.net 5 MVC6项目,并添加以下内容:

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

app.UseStatusCodePages();

我的配置方法内。如果我运行的应用程序,打开我的Web浏览器,定位到以下网址:

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

http://localhost:34741/invalidroute 

我是一个psented $ P $:状态code:404;未找到错误。这是预期的,但是如果我做的路线比较复杂,例如:

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/

我是一个HTTP错误404.20 psented $ P $ - 找不到IIS详细的错误页面。这是为什么不再由ASP处理?

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

我曾尝试与我的web.config文件httpErrors玩弄,我也试着设置在IIS默认文档,但我不能让一个自定义错误页的工作:(

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

推荐答案

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

404.20来自IIS。有一个设置maxurlSegments来控制多少段都是允许的,你可以找到在

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 /网站/网站/限制

修改的IIS设置和错误应该走了。

Modify that IIS setting and the error should go away.

这篇关于404.20异常不被ASP.net核心抓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆