[英]Can a “MVC 5 route” be used as a path in an error element in system.webServer httpErrors section in web.config?
Can a "MVC 5 route" be used as a path
in an error
element in system.webServer
httpErrors
section in web.config? 是否可以将“ MVC 5路由”用作web.config的system.webServer
httpErrors
部分中error
元素中的path
?
<configuration>
...other config stuff...
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="404"/>
<error statusCode="404" path="/Error/NotFound" responseMode="ExecuteURL"/>
</httpErrors>
</system.webServer>
</configuration>
Yes, you can do that. 是的,你可以这么做。 With responseMode="ExecuteURL"
IIS internally "redirects" (sends a request for the given URL) and writes the result to the response. IIS使用responseMode="ExecuteURL"
内部“重定向”(发送对给定URL的请求)并将结果写入响应。
You might also want to set the existingResponse
attribute in httpErrors
to Replace
. 您可能还希望将httpErrors
的existingResponse
属性设置为Replace
。
Be aware that: 意识到:
For architectural reasons, IIS 7.0 can only execute the URL if it is located in the same Application Pool. 出于体系结构原因,IIS 7.0如果位于同一应用程序池中,则只能执行URL。 Use the redirect feature to execute a Custom Error in a different Application Pool. 使用重定向功能可以在其他应用程序池中执行自定义错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.