asp.net mvc - 具有 HandleError 属性的自定义错误页面



>我 asp.net Web应用程序并尝试为动态IP限制模块指定自定义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>

产品环境(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.
<httpErrors existingResponse="Auto">

能解决问题

最新更新