pea*_*ewg 11 configuration iis-7
我正在构建一个包含自定义错误页面的新站点.我已经设置了我的web.config,并设置了所有页面.
当我在本地运行时,强制错误(找不到页面很容易),一切正常.但是当我发布到我的Windows Server 2008 R2生产服务器并输入错误页面时,它仍然会将我带到默认的IIS7错误页面.
这是我的web.config中的一个示例(我的页面都在那里):
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<customErrors mode="On" defaultRedirect="~/ErrorGeneral">
<error statusCode="400" redirect="~/ErrorBadRequest" />
<error statusCode="401" redirect="~/ErrorUnathorized" />
<error statusCode="402" redirect="~/ErrorPaymentRequired" />
<error statusCode="403" redirect="~/ErrorForbidden" />
<error statusCode="404" redirect="~/ErrorItemNotFound" />
<error statusCode="405" redirect="~/ErrorMethodNotAllowed" />
<error statusCode="406" redirect="~/ErrorNotAcceptable" />
<error statusCode="412" redirect="~/ErrorPreconditionFailed" />
<error statusCode="500" redirect="~/ErrorInternalServerError" />
<error statusCode="501" redirect="~/ErrorNotImplemented" />
<error statusCode="502" redirect="~/ErrorBadGateway" />
</customErrors>
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我做错了吗?它与Windows Server 2008 R2有何不同?
编辑:我发现问题,这是web.config文件中的附加信息,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="On" defaultRedirect="~/ErrorGeneral">
<error statusCode="400" redirect="~/ErrorBadRequest" />
<error statusCode="401" redirect="~/ErrorUnathorized" />
<error statusCode="402" redirect="~/ErrorPaymentRequired" />
<error statusCode="403" redirect="~/ErrorForbidden" />
<error statusCode="404" redirect="~/ErrorItemNotFound" />
<error statusCode="405" redirect="~/ErrorMethodNotAllowed" />
<error statusCode="406" redirect="~/ErrorNotAcceptable" />
<error statusCode="412" redirect="~/ErrorPreconditionFailed" />
<error statusCode="500" redirect="~/ErrorInternalServerError" />
<error statusCode="501" redirect="~/ErrorNotImplemented" />
<error statusCode="502" redirect="~/ErrorBadGateway" />
</customErrors>
</system.web>
<system.webServer>
<httpErrors>
<remove statusCode="502" subStatusCode="-1" />
<remove statusCode="501" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="412" subStatusCode="-1" />
<remove statusCode="406" subStatusCode="-1" />
<remove statusCode="405" subStatusCode="-1" />
<remove statusCode="403" subStatusCode="-1" />
<remove statusCode="401" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/Pages/ErrorItemNotFound.aspx" responseMode="ExecuteURL" />
<error statusCode="401" prefixLanguageFilePath="" path="/Pages/ErrorUnauthorized.aspx" responseMode="ExecuteURL" />
<error statusCode="403" prefixLanguageFilePath="" path="/Pages/ErrorForbidden.aspx" responseMode="ExecuteURL" />
<error statusCode="405" prefixLanguageFilePath="" path="/Pages/ErrorMethodNotAllowed.aspx" responseMode="ExecuteURL" />
<error statusCode="406" prefixLanguageFilePath="" path="/Pages/ErrorNotAcceptable.aspx" responseMode="ExecuteURL" />
<error statusCode="412" prefixLanguageFilePath="" path="/Pages/ErrorPreconditionFailed.aspx" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/Pages/ErrorInternalServerError.aspx" responseMode="ExecuteURL" />
<error statusCode="501" prefixLanguageFilePath="" path="/Pages/ErrorNotImplemented.aspx" responseMode="ExecuteURL" />
<error statusCode="502" prefixLanguageFilePath="" path="/Pages/ErrorBadGateway.aspx" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
Kev*_*Kev 19
默认情况下,IIS7拦截HTTP状态代码,例如由管道上的应用程序生成的4xx和5xx.
您可以告诉IIS只传递现有响应,而不用其自己的错误页面替换它:
<configuration>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅
归档时间: |
|
查看次数: |
12421 次 |
最近记录: |