【问题标题】:Custom error pages with HandleError attribute具有 HandleError 属性的自定义错误页面
【发布时间】:2013-01-22 12:07:44
【问题描述】:

我有 asp.net Web 应用程序并尝试为 Dynamic Ip Restrictions module 指定自定义 HTML,它在 .net 代码之前返回 401。

我在 web.config 中添加了以下内容:

<httpErrors>
  <remove statusCode="404" subStatusCode="-1" />
  <remove statusCode="401" subStatusCode="-1" />
  <error statusCode="401" path="ddos.html" responseMode="File" />
  <error statusCode="401" subStatusCode="502" path="ddos.html" responseMode="File" />
  <error statusCode="404" prefixLanguageFilePath="" path="/404" responseMode="ExecuteURL" />
</httpErrors>

Productin 环境(Windows Server 2008):带有 404 和 401 的页面工作正常,但异常处理被破坏 - 我看到内置 iis“红色”页面而不是自定义页面。

开发环境(windows 7/8):404和错误都可以,但是401会将用户重定向到登录页面。

异常处理定义为:

[HandleError(View = "Error", Master = "~/Views/Shared/_ThreeColumnsLayout.cshtml")]

UPD1:另外,我可以补充一点,如果我删除代码为 500 的页面,我会看到以下纯文本消息:

The page cannot be displayed because an internal server error has occurred.

【问题讨论】:

    标签: asp.net-mvc iis web-config handleerror ip-restrictions


    【解决方案1】:
    <httpErrors existingResponse="Auto">
    

    成功了

    【讨论】:

    • 您是否对异常处理中的响应进行了特殊处理?当我这样做时,无论我做什么,它都不起作用,并且我得到“错误请求”作为内容。我必须设置“TrySkipIisCustomErrors”。
    猜你喜欢
    • 1970-01-01
    • 2012-05-30
    • 2019-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-16
    相关资源
    最近更新 更多