404错误页面配置

1.在<system.web>下添加(主要针对访问页面报错等):

<customErrors mode="On" defaultRedirect="error/error.htm" >
  <error statusCode="500" redirect="error/error.htm"/>
  <error statusCode="404" redirect="error/404.htm"/>
  <error statusCode="403" redirect="error/error.htm"/>
</customErrors>

2.在<system.webServer>下添加(主要针对访问文件夹或不存在的文件夹报错):

<httpErrors errorMode="Custom">        
    <remove statusCode="403" />
    <remove statusCode="404" />            
    <error statusCode="403" path="/error/404.htm" responseMode ="Redirect"/>
    <error statusCode="404" path="/error/404.htm" responseMode ="Redirect"/>            
</httpErrors>

 

posted @ 2018-10-23 11:59  张伟大  阅读(108)  评论(0编辑  收藏  举报