1

我的 web.config 中的 CustomErrors 指令正在工作,除了 404 之外,IIS 提供没有 ContentType 标头的 302 重定向。这会导致防火墙阻止响应,并且客户端永远不会访问自定义错误页面。注意我使用的是 IIS7、MVC (razor)、ELMAH,并支持各种浏览器。

<customErrors defaultRedirect="~/Site/Error" mode="RemoteOnly" />

如何在所有 CustomError 重定向中获得合理的 Content-Type 标头,或者以其他方式解决问题?

4

1 回答 1

1

您可以尝试像此人在此处所做的那样编写自定义 HTTP 模块:

http://www.colincochrane.com/post/2008/01/ASP-NET-Custom-Errors-Preventing-302-Redirects-To-Custom-Error-Pages.aspx

于 2012-06-06T19:44:52.153 回答