-1

I am trying to route a request

/api/someName.xml?param1=123

I tried routing all requests to my default controller - MyController and it will route a call like:

http://localhost:54865/api/someName?param1=312.1232&param2=13.321

but I need not route a request like

http://localhost:54865/api/someName.xml?param1=312.1232&param2=13.321

I am not able to do that right now with the following Route map entry:

config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{*uri}",
                defaults: new { controller = "MyController"});

how can I allow endpoints with extension (someName.xml) to be routed?

Thanks

ak1984
  • 373
  • 1
  • 3
  • 10

1 Answers1

0

I found the answer at ASP.net MVC4 WebApi route with file-name in it

Solution - in the Web.config file, just add the following xml attribute under the <handlers> section of <system.webServer>

<add
          name="ManagedDllExtension"
          path="api/*.xml"
          verb="GET"
          type="System.Web.Handlers.TransferRequestHandler"
          preCondition="integratedMode,runtimeVersionv4.0"/>
Community
  • 1
  • 1
ak1984
  • 373
  • 1
  • 3
  • 10
  • Not that this has any inpact on the code, but I would probably change the name to MangedXmlExtention in this case. – hormberg Nov 16 '18 at 09:30