默认情况下,静态文件似乎不会走 asp.net mvc 的路由,直接会由 iis 返回静态文件,或 404 错误。

这时,需要在 web.config 中配置具体哪些文件需要经过路由处理(在 system.webServer/handlers 下):

<add name="XmlFileHandler" path="*.xml" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

参考:

https://stackoverflow.com/questions/22159419/asp-net-mvc-routing-an-action-with-file-extension

https://weblog.west-wind.com/posts/2015/Nov/13/Serving-URLs-with-File-Extensions-in-an-ASPNET-MVC-Application

相关文章:

  • 2022-12-23
  • 2021-10-03
  • 2021-05-01
  • 2021-09-18
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2021-07-13
  • 2021-12-29
  • 2021-10-23
  • 2021-12-26
  • 2022-12-23
  • 2021-09-10
相关资源
相似解决方案