I use this code.
using System.Web.Mvc;
public ActionResult DamePdf(LDModel ld, string returnUrl)
{
string contentType = System.Net.Mime.MediaTypeNames.Application.Pdf;
return new FilePathResult(ld.fullPathfileName, contentType)
//{
// FileDownloadName = ld.FileName,
//};
}
The action, instead of returning a view, will return a file.
if the last 3 lines are uncommented, when the file arrives it will be saved directly in the browser's download folder with the name that we put it. If so, the name should end in .pdf
Having a name, it depends on the explorer, the behavior may be different. Some keep it without asking, others show it without asking and others ask in any case. When it does not have a name, some explorers, the good ones, open it directly.
If you change the line where contentType is defined by:
string contentType = System.Net.Mime.MediaTypeNames.Application.Octet;
Specifically Crhome saves it directly without asking anything.