[英]Custom error redirection through web.config does not work
I`m trying to implement redirect to custom error pages, when error happens. 当发生错误时,我正在尝试实现重定向到自定义错误页面的操作。
I tried next way: 我尝试了另一种方式:
<customErrors mode="On" redirectMode="ResponseRewrite">
<error statusCode="403" redirect="/Errors/AccessDenied" />
<error statusCode="404" redirect="/Errors/PageNotFound" />
</customErrors>
And also method with <httperrors>
inside web.server tag. 还有在web.server标记中带有
<httperrors>
方法。
None of the methods works. 这些方法均无效。 Instead of redirecting to error pages, i see default error:
我看到默认错误,而不是重定向到错误页面:
What you can advice to solve that problem? 您有什么建议可以解决该问题? I`ll be very gratefull to any help
我将非常感谢您的帮助
It looks like the screen is throwing a http 404 error. 屏幕似乎抛出了HTTP 404错误。 Assuming you have no other overriden methods for catching these errors in your application, try adding the following to the web.config
假设您没有其他重写方法来捕获应用程序中的这些错误,请尝试将以下内容添加到web.config中
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" path="/Errors/whatever" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
Did you try remove status code 404? 您尝试删除状态码404吗?
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/Errors/PageNotFound" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.