自定义错误重定向不工作 [英] Custom error redirects not working
问题描述
我想,以确保没有不规范的错误信息发送到用户出于安全原因。一般来说,我有标准的错误消息的设置和它完美的罚款。我用这些标记在web.config:
I'm trying to ensure that no non-standard error messages are sent to a user for security reasons. Generally I have standard error messages setup and it works perfectly fine. I use these tags in the web.config:
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1"/>
<remove statusCode="401" subStatusCode="-1"/>
<remove statusCode="403" subStatusCode="-1"/>
<remove statusCode="501" subStatusCode="-1"/>
<remove statusCode="400" subStatusCode="-1"/>
<remove statusCode="411" subStatusCode="-1"/>
<error statusCode="403" path="/ErrorPages/UnAuthorized.aspx" responseMode="ExecuteURL"/>
<error statusCode="404" path="/ErrorPages/Oops.aspx" responseMode="ExecuteURL"/>
<error statusCode="501" path="/ErrorPages/Oops.aspx" responseMode="ExecuteURL"/>
<error statusCode="400" path="/ErrorPages/Oops.aspx" responseMode="ExecuteURL"/>
<error statusCode="411" path="/ErrorPages/Oops.aspx" responseMode="ExecuteURL"/>
<error statusCode="400" path="/Account/Login.aspx" responseMode="ExecuteURL"/>
</httpErrors>
我遇到的问题是,它已经指出,一些403400501错误信息仍然没有被重定向。
The problem I am having is it has been pointed out that some 403,400,501 error messages still don't get redirected.
这是导致此问题的网址是:
The urls that cause this problem are:
www.example.com/con/ - asp.net error
wwww.example.com/..%5CStorage%5CDocuments%5C8849145d-174a-41ab-9676-0ae19d6ab741 - 403 error
和来自无效的内容长度411错误。
and 411 errors from invalid content length.
推荐答案
您使用的VisualStudio开发服务器IIS7或防爆preSS?
如果你正在使用它,那么你应该尝试:
Are you using VisualStudio Development Server or IIS7 Express? If you are using it then you should try with:
<customErrors mode="On" >
<error statusCode="503" redirect="/Views/Shared/Error.htm"/>
</customErrors>
如果没有,试试这个:
<httpErrors existingResponse="Replace" defaultResponseMode="Redirect" errorMode="Custom">
<remove statusCode="501"/>
<error statusCode="501" responseMode="Redirect" path="/ErrorPages/Oops.aspx"/>
</httpErrors>
这篇关于自定义错误重定向不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!