IIS httpErrors ExecuteURL 将奇怪的查询字符串(如 500;http://mysite.com/failed-page)附加到目标 URL

bun*_*nny 11 iis iis-7.5

我注意到 IIS 错误页面中的奇怪行为。我有这个设置:

<httpErrors errorMode="Custom" existingResponse="Replace">
 <remove statusCode="500" />
  <error statusCode="500" responseMode="ExecuteURL" path="/error-page" />
</httpErrors>
Run Code Online (Sandbox Code Playgroud)

有时,当由于查询字符串太长而导致 ASP.NET 错误时,在尝试执行错误页面 URL 时会立即发生第二个错误。我已经将问题跟踪到 IIS 将原始 url 附加到错误页面 url 的事实,例如:

Original: http://example.com/someurl?id=some_very_long_query_string_causing_security_exception
Error: /error-page?500;http://example.com/someurl?id=some_very_long_query_string_causing_security_exception
Run Code Online (Sandbox Code Playgroud)

这是一个巨大的问题。如果原始 url 因查询字符串太长而失败,那么带有附加内容的错误页面也会失败,因为它的查询字符串更长!

我相信这是 IIS 中最愚蠢的错误。有谁知道是否有一些服务包补丁?最坏的情况是,如果现在什么都没有解决,有没有办法禁用这种行为或任何技巧来阻止 IIS 将未经请求的内容附加到错误页面?因为它打破了整个自定义错误页面机制。

小智 0

我很久以前就遇到过类似的问题,因此有问题的系统使用静态错误页面。

您可以在 defaultResponseMode 中将其设置为 file,它将返回单个静态页面。

httpErrors 元素 IIS 设置架构

这里也有类似的问题