日期:2014-05-17  浏览次数:20431 次

请问aspx页面如何设置404错误页面呢?
我自己设置了一个404.aspx与error.htm两个页面,我在IIS里将404页面自定义到error.htm后,所以页面后缀为htm或者html的错误页面都自动跳到error.htm页面了,可是不存在的aspx页面却还总是显示下面404错误,请问为什么呢??


而且我也在web.config文件里设置了
<customErrors redirectMode="ResponseRewrite" mode="Off" defaultRedirect="~/404.aspx">
  <error statusCode="404" redirect="~/404.aspx"/>
  </customErrors>
可aspx页不存在时仍没有用


The resource cannot be found. 
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /404d.aspx


------解决方案--------------------
打开IIS管理器–>点击要设置自定义404的网站的属性–>点击自定义错误选项–>选中404页–>选中并打开编辑属性–>设置成 URL –> URL 里填写“/404.html”–>按确定退出再把做好的404.html 页面上传到网站根目录下。此处在“消息类型”中一定要选择“文件”或“默认值”,而不要选择“URL”,不然,将导致返回“200”状态码。

------解决方案--------------------
配置文件Web.config