I have an MVC project that will display some documents to users. The files are currently stored in Azure blob storage.
Currently, the documents are retrieved from the following controller action:
[GET("{zipCode}/{loanNumber}/{classification}/{fileName}")]
public ActionResult GetDocument(string zipCode, string loanNumber, string classification, string fileName)
{
// get byte array from blob storage
byte[] doc = _docService.GetDocument(zipCode, loanNumber, classification, fileName);
string mimeType = "application/octet-stream";
return File(doc, mimeType, fileName);
}
Right now, when a user clicks on a link like the following:
<a target="_blank" href="http://...controller//GetDocument?zipCode=84016&loanNumber=12345678classification=document&fileName=importantfile.pdf
Then, the file downloads to their browser's downloads folder. What I would like to happen (and I thought was default behavior) is for the file to simply be displayed in the browser.
I have tried changing the mimetype and changing the return type to FileResult instead of ActionResult, both to no avail.
How can I make the file display in the browser instead of downloading?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…