I've built a controller in MVC 5 to handle file downloads protected by login. The controller works fine without the pdf extension, ie paths like /media/1001/secretpdffile will download a file at App_Data/media/1001/secretpdffile.pdf only if the user is logged in.
I would like to have the pdf extension on the paths but as soon as I add it (of course also dropping the pdf I'm adding in the controller) that I get a 404 error.
This is my route
routes.MapRoute(
name: "Media",
url: "media/{mediaid}/{filename}",
defaults: new { controller = "Media", action = "Get" }
);
I've seen a lot of places that try to solve this with <httpRuntime relaxedUrlToFileSystemMapping="true" /> or with setting a path with System.Web.Handlers.TransferRequestHandler in web.config but I haven't had any luck with that.