I am trying to create a simple WebDAV server using MVC, and I finally reached the stage where I need to transfer the requested file to the user.
I have a route that deals with moving the directory structure "webdav/{*path}" , which works fine, right up until the moment when this path ends with the file name. At the moment, it seems that IIS is deciding that it is a static file, and is trying to serve this file from disk. Since it is not specified in the URL, it returns a 404 error.
I donβt have any freedom to change the URL, I basically need it to be in shape, otherwise Windows Explorer cannot work with it as a mapped drive:
GET /webdav/Test/Test2.txt
I set the route for greedy matching, since the directory structure can have so many levels. I also set routes.RouteExistingFiles = true;
This uses IIS Express 8.0 on my development machine.
I went as far as creating an empty MVC project to test this, and this is the RegisterRoutes method:
routes.RouteExistingFiles = true; routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "WebDAVGet", url: "webdav/{*path}", defaults: new { controller = "WebDAV", action = "Get", path = "" }); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } );
So, going to /webdav/Test/Test2 gets to a breakpoint in my controller, but going to /webdav/Test/Test2.txt gives me 404.
Any suggestions?
Paul manzotti
source share