我一直在尝试让我的网络应用程序重定向到自定义 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/