views:

63

answers:

2

I have an application where I allow my users to upload a file of any type. I save this in the file system on the server. The applciation will only be accessed by two users , so I don't need to worry about uploading any dodgy files.

How do I allow my user to press a button on an MVC form to request the file be sent back via the browser and be presented with the standard save/open dailog?

I want to return any type of file, and the example I've found always specify the type of file being returned. Is there a simple example of this?

Thanks! :)

+2  A: 

See FileResult and derived classes.

Anton Gogolev
A: 

An alternative approach is to set HttpContext.Response.ContentType to the proper mimetype and then writing the contents of the file with HttpContext.Response.OutputStream.Write ().

Useful if, for example, the data is not in a local file but stored in a database as a binary blob.

axel_c