且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET MVC - 路由 - 带有文件扩展名的操作

更新时间:2022-12-08 19:22:57

您需要将 XML 文件的请求映射到 web.config 中的 TransferRequestHandler.否则 IIS 将处理请求.

You need to map requests for your XML files to TransferRequestHandler in web.config. Otherwise IIS will handle the request.

Jon Galloway 解释了如何做到这一点 此处.

Jon Galloway explains how to do this here.

总而言之,您将此元素添加到 web.config 中的 location/system.webServer/handlers:

In summary, you add this element to location/system.webServer/handlers in your web.config:

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