2016-04-27 66 views
0

我想在我的应用程序中收到403错误时重定向到一个html文件。这是通过IIS来处理,所以我必须加入到这个我的web配置:httpErrors - 将403重定向到HTML文件 - 如何?

<httpErrors errorMode="Custom" > 
     <remove statusCode="403"/> 
     <error statusCode="403" responseMode="File" path="/500.html"/> 
    </httpErrors> 

这给了我这个错误:

You do not have permission to view this directory or page. 

但是,如果我改变响应模式ExecuteURL它会重定向到页。但它会显示一个200的http状态码,而文件会保持403错误。我只是无法让它重定向到这个文件。

任何人都可以帮我解决这个问题吗?

回答

0

根据该system.webserver/httperrors/error配置节点(https://www.iis.net/configreference/system.webserver/httperrors/error)的描述中,responseMode属性设置为File需要provding绝对视窗路径到错误页面。如下例所示:

<configuration> 
    <system.webServer> 
     <httpErrors errorMode="DetailedLocalOnly" defaultResponseMode="File" > 
     <remove statusCode="500" /> 
     <error statusCode="500" 
      prefixLanguageFilePath="C:\Contoso\Content\errors" 
      path="500.htm" /> 
     </httpErrors> 
    </system.webServer> 
</configuration>