2016-04-27 14 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>