225025 发表于 2015-11-15 09:14:18

IIS 指定404页面

<system.webServer>
  <httpErrors errorMode=&quot;Custom&quot; existingResponse=&quot;Replace&quot;>
  

    <remove statusCode=&quot;500&quot; subStatusCode=&quot;-1&quot; />
    <remove statusCode=&quot;404&quot; subStatusCode=&quot;-1&quot; />
    <error statusCode=&quot;404&quot; prefixLanguageFilePath=&quot;&quot; path=&quot;error.htm&quot; responseMode=&quot;File&quot; />
    <error statusCode=&quot;500&quot; prefixLanguageFilePath=&quot;&quot; path=&quot;error.htm&quot; responseMode=&quot;File&quot; />
</httpErrors>
</system.webServer>

<system.web>
<customErrors mode=&quot;Off&quot; />
  </system.web>
  

  
  ExistingResponse:建议选用Replace
  ExistingResponse属性开关在httpErrors中 (属于asp.net报错)。这个开关是决定谁来抛出异常,它有三个模式

[*]Auto 默认错误页面 Asp.net或IIS
[*]Replace 强制IIS
[*]PassThrough 强制Asp.net
  
  由于我们为了安全因素的考虑。通常的配置需要把程序级开发报错页面对内显示,对外则用友好的报错页面。
  我们需要用到Replace强制IIS报错,这样可以解决对外抛出详细的.Net开发报错页面。只有当要查找问题时
  才调到 PassThrough模式,打开.net错误页面。
  

  <httpErrors errorMode=&quot;Detailed&quot; />项,而虚拟主机控制面板又可以自定义404,只要把errorMode的值修改为Custom即可。
在这里说明下:
errorMode有三个值,建议选用DetailedLocalOnly


[*]Custom:对用户与服务器端始终显示自定义页面


[*]DetailedLocalOnly:只能服务器端显示详细出错信息


[*]Detailed:对用户与服务器端始终显示详细出错信息。
  

         版权声明:本文为博主原创文章,未经博主允许不得转载。
页: [1]
查看完整版本: IIS 指定404页面