In asp.net mvc, how to handle routing of url extensions with file

By default, static files does not seem to go the route asp.net mvc direct return static files, or 404 errors caused by iis.

In this case, you need to configure in web.config which files need to go through the specific routing treatment (system.webServer / handlers below):

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

reference:

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

Guess you like

Origin www.cnblogs.com/xwgli/p/12348358.html