Return File(document.Data, document.ContentType, document.Name) These are the examples of what I've tried so far. If I force the file name by specifying it, I lose the ability for the browser to open the file directly and I get a download prompt. I have tried FileStreamResult and it works for most files, its constructor doesn't accept a filename by default, so unknown files are assigned a file name based on the URL (which does not know the extension to give based on content type). But I also want to keep a download link off to the side so that I can force a download prompt regardless of the file type. However, if I choose to view a file called SomeRandomFile.pdf or SomeRandomFile.jpg I want the file to simply open. If I choose to view a file called SomeRandomFile.bak and the browser doesn't have an associated program to open files of this type, then I have no problem with it defaulting to the download behavior. What I want is a view listing two links, one to view the file and let the mimetype sent to the browser determine how it should be handled, and the other to force a download. I'm encountering a problem sending files stored in a database back to the user in ASP.NET MVC.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
June 2023
Categories |