Prevent static file handler from intercepting filename-like URL

后端 未结 2 1808
醉话见心
醉话见心 2021-01-04 05:30

In my web application I have a route which looks like this:

routeCollection.MapRoute(
    \"AdfsMetadata\",                    


        
2条回答
  •  清酒与你
    2021-01-04 06:15

    IIS by default is serving that file as static withouth going into ASP pipeline, can you change the route to not have a .xml extension (which is not necessary at least you have a specific requirement about that)

    You can specifiy the route like this:

    routeCollection.MapRoute(
    "AdfsMetadata",                                                // name
    "FederationMetadata/2007-06/FederationMetadata",               // url
    new { controller = "AdfsController", action = "MetaData" });   // defaults
    

    Other solution would be to add to your web.config

    
    

    but I recommend you to avoid this as possible since what it does is to stop IIS from serving all static files

    EDIT Last try... a custom http handler for that specific path would work. This post is similar to your problem only that with images (look for "Better: Custom HttpHandlers" section)

提交回复
热议问题