简体   繁体   English

是否可以将“ MVC 5路由”用作web.config的system.webServer httpErrors部分中错误元素中的路径?

[英]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 . 您可能还希望将httpErrorsexistingResponse属性设置为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.

相关问题 重写如何在web.config system.webserver中工作 - How does the rewrite works in web.config system.webserver HTTP错误500.19 - 内部服务器错误 - system.webServer / httpErrors缺少部分声明 - HTTP Error 500.19 - Internal Server Error - system.webServer/httpErrors is missing a section declaration web.config httpErrors部分和WebAPI区域可以共存吗? - Can web.config httpErrors section and a WebAPI area coexist? 在web.config中使用httpErrors时未命中错误控制器 - Error controller not hit when using httpErrors in web.config 通过删除所有IIS错误消息 <httpErrors> 在web.config中 - Remove all IIS error messages via <httpErrors> in web.config 我如何使用HttpResponseMessage HttpStatusCode分隔web.config httpErrors - How can i separate web.config httpErrors with HttpResponseMessage HttpStatusCode httpError在web.config中的localhost上不起作用 - httpErrors not working on localhost in web.config 找不到 Web.Config 和 System.Web.MVC - Can not find Web.Config and System.Web.MVC Web.config。 当路径在httpErrors defaultPath部分中是相对路径时找不到文件 - Web.config. File not found when path is relative in httpErrors defaultPath section 如何从web.config中读取system.web部分 - How to read system.web section from web.config
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM