Is there a way to force PDF files to open in the browser when the option \"Display PDF in browser\" is unchecked?
I tried using the embed tag and an iframe, but it o
This is for ASP.NET MVC
In your cshtml page:
@Model.Name
In your controller:
public ActionResult Download(Guid id)
{
if (id == Guid.Empty)
return null;
var model = GetModel(id);
return File(model.FilePath, "application/pdf", model.FileName);
}
public FileStreamResult View(Guid id)
{
if (id == Guid.Empty)
return null;
var model = GetModel(id);
FileStream fs = new FileStream(model.FilePath, FileMode.Open, FileAccess.Read);
return File(fs, "application/pdf");
}