2013-07-14 113 views
0

如果可以的話,需要一些幫助。結合web.config文件

一個是允許.html和.htm文件的行爲類似.asp文件的一些包括和另一個是自定義的404頁面。

我試過了各種各樣的變化,但是除了單獨使用這些文件之外,所有的東西都給我一個'500 - 內部服務器錯誤'的信息。

web.config中1:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
<system.webServer> 
<handlers> 
<add name="htmlinc" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" /> 
<add name="htminc" path="*.htm" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" /> 
</handlers> 
</system.webServer> 
</configuration> 

web.config中2:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
<system.webServer> 
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/404.htm" defaultResponseMode="ExecuteURL"> 
<remove statusCode="404" subStatusCode="-1" /> 
<error statusCode="404" prefixLanguageFilePath="" path="/404.htm" responseMode="ExecuteURL" /> 
</httpErrors> 
</system.webServer> 
<system.web> 
<customErrors mode="On"> 
<error statusCode="404" redirect="/404.htm" /> 
</customErrors> 
</system.web> 
</configuration> 

回答

0

這應該工作。檢查父級web.config文件並通過繼承查找問題。

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
<system.webServer> 
<handlers> 
<add name="htmlinc" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" /> 
<add name="htminc" path="*.htm" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" /> 
</handlers> 
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/404.htm" defaultResponseMode="ExecuteURL"> 
<remove statusCode="404" subStatusCode="-1" /> 
<error statusCode="404" prefixLanguageFilePath="" path="/404.htm" responseMode="ExecuteURL" /> 
</httpErrors> 
</system.webServer> 
<system.web> 
<customErrors mode="On"> 
<error statusCode="404" redirect="/404.htm" /> 
</customErrors> 
</system.web> 
</configuration>