0

So I have this route

        routes.MapRoute(
            name: "GetLinkJSON",
            url: "getlinkjson/{property}/{version}/{friendlyFileName}",
            defaults: new {controller = "Home", action = "GetLinkJSON"}
        );

and this controller method

        public ActionResult GetLinkJSON(string property, int version, string friendlyFileName, string message, string key)

URLs like this work well

/getlinkjson/elms/1/testdisc096img?message=foo&key=bar

but this fails to match (when I add the . back into the friendlyFileName param)

/getlinkjson/elms/1/testdisc096.img?message=foo&key=bar

I tried changing {friendlyFileName} to {*friendlyFileName} to be a catch all, but no luck.

  • Possible duplicate of [ASP.NET MVC - Routing - an action with file extension](http://stackoverflow.com/questions/22159419/asp-net-mvc-routing-an-action-with-file-extension). This may not seem like a duplicate, but the same principle is in play. By default, URLs with extensions are handled directly by IIS and not thrown to the routing framework in MVC. – Chris Pratt Aug 07 '14 at 18:48

2 Answers2

0

You can try this setting in web.config

<httpRuntime relaxedUrlToFileSystemMapping="true" /> 

If even that does not work , you can use ASP.NET Route Debugger to debug and see whats happening , here is helpful link.
http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx/

Ajay Kelkar
  • 4,591
  • 4
  • 30
  • 29
0

This is a little late, but I used this in web.config and it worked:

  <add name="ApiURIs-ISAPI-Integrated-4.0"
   path="/people/*"
   verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS"
   type="System.Web.Handlers.TransferRequestHandler"
   preCondition="integratedMode,runtimeVersionv4.0" />
Dicer
  • 396
  • 6
  • 13