在IIS 7中:如何为任何错误设置默认的错误文档

我想用户'error.html'的任何错误IIS可能遇到。

如果我在我的webconfig中声明以下块,站点拒绝运行。

<httpErrors errorMode="DetailedLocalOnly" existingResponse="Replace" defaultPath="/error.html" defaultResponseMode="ExecuteURL"> <remove statusCode="500" subStatusCode="-1" /> <remove statusCode="404" subStatusCode="-1" /> <remove statusCode="403" subStatusCode="-1" /> <remove statusCode="401" subStatusCode="-1" /> <error statusCode="401" prefixLanguageFilePath="" path="/401.html" responseMode="ExecuteURL" /> <error statusCode="403" prefixLanguageFilePath="" path="/403.html" responseMode="ExecuteURL" /> <error statusCode="404" prefixLanguageFilePath="" path="/404.html" responseMode="ExecuteURL" /> <error statusCode="500" prefixLanguageFilePath="" path="/500.html" responseMode="ExecuteURL" /> </httpErrors> 

注意根元素中的属性defaultPath =“/ error.html”

我收到以下错误

HTTP-Fehler 500.19 – 内部服务器错误

Konfigurationsfehler:Sperrverletzung

编辑%windir%\ system32 \ inetsrv \ config \ applicationHost.config

设置线路:

 <httpErrors lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath"> 

至:

 <httpErrors lockAttributes="allowAbsolutePathsWhenDelegated"> 

尝试使用IIS 7pipe理器来正确设置。 另外,你也许可以这样做:

 <system.web> <customErrors mode="On" defaultRedirect="~/error.html"> </customErrors> </system.web> 

除了Fabian的回答,您还可以在以下位置find该文件:

解决scheme文件夹 – > .vs(通常这个文件夹是隐藏的) – > config