我的网站是.htm扩展名,服务器是IIS 7.我现在设计了自定义404页面。
现在有人可以建议我,如何通过web.config实现自定义404页面。
答案 0 :(得分:12)
我在IIS7中的.htm
页面也遇到了同样的问题(不是ASP,不是.NET)。
我在responseMode
中将File
更改为ExecuteURL
而不是<system.webServer>
,一切正常:
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" responseMode="File" path="error.htm" />
</httpErrors>
答案 1 :(得分:5)
在web.config
文件中使用此功能:
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" responseMode="ExecuteURL" path="/Errors/NotFound" />
</httpErrors>