asp.net - .aspx 扩展名的自定义 404 页面错误

标签 asp.net .net http-status-code-404 episerver

我一直在尝试让我的网络应用程序重定向到自定义 404 页面。它适用于所有网址,除非它们具有“.aspx”扩展名

服务器是 Windows Server 2008,以下是我在 web.config 中的以下设置(使用 google.com 作为简单示例):

<customErrors defaultRedirect="http://www.google.com" mode="On" redirectMode="ResponseRedirect"></customErrors>

<httpErrors errorMode="Custom">
<clear />
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404-Page/" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/404-Page/" responseMode="ExecuteURL" />
</httpErrors>

HTTP 错误同样适用于除“.aspx”扩展名之外的所有内容

最佳答案

customErrors 元素提供有关 ASP.NET 应用程序的自定义错误消息的信息。尝试将 error 子元素添加到您要捕获的特定 HTTP 错误代码的 customErrors 元素。

<error statusCode="404" redirect="error404.htm"/>

关于asp.net - .aspx 扩展名的自定义 404 页面错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12467757/

相关文章:

http-status-code-404 - 如何用实际的 404 状态代码响应替换 Blazor 默认值 "soft 404"

c# - 在 asp.net 中保存和检索 session 状态的值

c# - 使用代码块渲染枚举值

c# - System.UnauthorizedAccessException 对一个简单的 ASP.Net File.IO 操作

.net - SignalR 中的多态性

apache - Apache:返回404错误而不是500错误

jquery - 试图理解为什么元兼容性标记解决了 jQuery 错误

c# - .NET 中的 "open generic type"到底是什么?

c# - 如何在 C# 中从字符串调用委托(delegate)?

javascript - 使用 XMLHttpRequest 抑制控制台错误