asp.net mvc - Handling WebDAV requests on MVC action -
i have existing mvc3 application allows users upload files , share them others. current model if user wants change file, have delete 1 there , re-upload new version. improve this, looking integrating webdav allow online editing of things word documents.
so far, have been using .net server , client libraries http://www.webdavsystem.com/ set website webdav server , talk it.
however, don't want users interact webdav server directly (we have complicated rules on users can in situations based on domain logic) go through previous controller actions had accessing files.
so far working point can return file , gives webdav-y type prompt opening file.
the problem is stuck in read-only mode. have confirmed works , editable if use direct webdav url not through controller action.
using fiddler think have found problem word trying talk negotiate server locking location isn't returning right details. controller action downloading file "/files/download?filepath=bla" , word trying talk "/files" when sends options request.
do need have action @ location know how respond options request , if so, how response? alternatively, there way it, perhaps adding property response inform word should looking instead?
here controller action:
public virtual fileresult download(string filepath) { filedetails file = _fileservice.getfile(filepath); return file(file.stream, file.contenttype); }
and here file service method:
public filedetails getfile(string location) { var filename = path.getfilename(location); var contenttype = contenttype.get(path.getextension(location)); string license ="license"; var session = new webdavsession(license) {credentials = credentialcache.defaultcredentials}; iresource resource = session.openresource(string.format("{0}{1}", configurationmanager.appsettings["webdavroot"], location)); resource.timeout = 600000; var input = resource.getreadstream(); return new filedetails { filename = filename, contenttype = contenttype, stream = input }; }
it still days on appreciate doing in entirely wrong way , form of welcome.
in end seems better option allow users directly talk webdav server , implement authentication logic control it.
the hit server has extensions allow authenticate against forms authentication rest of site using basic or digest authentication office. using along other customisations item request logic gave needed.
Comments
Post a Comment