【发布时间】:2015-02-23 23:23:14
【问题描述】:
我有一个 .Net 网站,其中包含使用 web.config httpErrors 部分配置的自定义错误页面:
<httpErrors errorMode="Custom" existingResponse="Replace">
<clear/>
<error statusCode="400" path="/page-not-found/" responseMode="ExecuteURL" />
<error statusCode="404" path="/page-not-found/" responseMode="ExecuteURL" />
<error statusCode="500" path="/error/" responseMode="ExecuteURL" />
</httpErrors>
和
<httpRuntime requestValidationMode="2.0" targetFramework="4.5" />
当我访问http://www.example.com/< 时,该站点会显示正确的“找不到页面”页面,但是如果我访问http://www.example.com/<a,它会显示一个带有 500 状态代码响应标头的 YSOD。
我已经连接了 Elmah,并且可以预见两个 URL 都会抛出完全相同的错误 System.Web.HttpException: A potentially dangerous Request.Path value was detected from the client (<).
但是为什么两个 URL 的处理方式不同呢?为什么一个被重写到我的自定义错误页面,而另一个没有?我希望任何异常都有相同的行为。
编辑:
我应该提前提到这是一个 Umbraco 项目。我认为这不是促成因素,但我创建了一个没有依赖项的准系统 .Net 项目,并且按预期工作,即两个 URL 都遵循 httpErrors 配置。所以这一定是 Umbraco 特有的东西,可能是一个模块。
【问题讨论】:
标签: asp.net exception configuration umbraco