using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web; using System.Web.Http; using WebDAVSharp.Server; using WebDAVSharp.Server.Adapters; using WebDAVSharp.Server.Stores.DiskStore; namespace WebDAVSharp.WebServer.Controllers { public class WebDAVController : ApiController { [Route("test"), HttpGet] public dynamic Test() { return new { bla = "blupp", kinz = "kunz" }; } [Route("webDav/{*FileName}"), AcceptVerbs("OPTIONS", "GET", "HEAD", "PROPFIND", "PROPPATCH", "MKCOL", "PUT", "DELETE", "COPY", "MOVE", "LOCK", "UNLOCK", "TRACE", "POST")] public void WebDav(String FileName) { var rootPath = @"t:\"; var store = new WebDavDiskStore(rootPath); var webDavServer = new WebDavServer(store); webDavServer.ServiceUrl = "http://" + Request.RequestUri.Authority + "/webDAV/"; // trailing slash is important webDavServer.ProcessRequest(HttpContext.Current, FileName); //HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); } } }