views:

224

answers:

3

We all know that it is possible to "open" a Word document (or file from any arbitrary application) by clicking on a website link and then clicking the Open button.

I also know that, if I want to upload an application document to a web server, I must first save the document to my computer, and then go to an upload page, click a file/open button, find my saved file and upload it.

But is it possible to save a document to a website location or Url, effectively skipping the first save step and uploading the file to the web server through the Save dialog of the application, directly?

How would this be done in ASP.NET MVC?

A: 

It really depends on how complex you want to make it. This is pretty much what "web folders" offered (via WebDAV), but in general it creates more problems than it will ever fix. I don't recommend this approach.

Your best bet to make this simple is a dedicated client app - perhaps (although this is a dubious example) how Office talks to sharepoint. In a simpler example, you could create a silverlight out-of-browser application that saved via a web-service to a site using WCF or similar.

Marc Gravell
Do you mean, "in general it *creates* more problems"?
Daniel Schilling
@Daniel oops, yes.
Marc Gravell
A: 

I think there is some creedence in what @Marc says. Personally I'd probably map a drive to the web site in question, if that's possible, and have a folder to upload to.

Then I'd have .Net check changes to the folder and take those files and import them into the repository, whatever that may be.

It's still an imperfect solution and I'm not sure there is a correct solution as yet.

I guess you could always write, and I can't believe I'm writing this, macros to save to the ftp location.

griegs
A: 

I'd guess you have a few choices, in no particular order:

  1. Web service that the application can reference and upload through.
  2. REST service (WCF or otherwise) that the application can POST to.
  3. HttpHandler or MVC controller action that the application can POST to.
  4. WebDAV directly to the server.

Number 3 sounds like it's closest to what you were looking for ("How would this be done in ASP.NET MVC?"). Scott Hanselman has a good article on handling file uploads in MVC on his blog.

When you implement the client, there's a little bit of a trick to that, too, since you can't just POST like usual; you have to post in multipart/form-data format. I posted a blog entry with some sample code on how to do that.

Travis Illig
I think I already have a solution for uploading files. What I don't have yet is a way to do it directly from a Windows application's Save/File dialog.
Robert Harvey