Open PDF in Adobe Reader, not in the browser.

when you click on the link via email, the following code opens the PDF document in the browser:

Response.ContentType = mime; Response.WriteFile(path); HttpContext.Current.ApplicationInstance.CompleteRequest(); 

Is there a way to get the client to open it natively in Adobe Acrobat / reader?

+4
source share
3 answers

How the client works depends on several things, including client-side settings ... you can try this

 Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment; filename="+filePath); Response.WriteFile(path); HttpContext.Current.ApplicationInstance.CompleteRequest(); 
+5
source
 Response.ContentType = "application/pdf"; Response.AppendHeader("Content-Disposition","attachment; filename=SailBig.pdf"); Response.TransmitFile( Server.MapPath("~/images/sailbig.pdf") ); Response.End(); 

here is some useful information: Uploading a file using the Save As dialog in ASPNET and C # dynamically rename the file after the download request and Processing file downloads using ASP.NET MVC if you use MVC

+2
source

The best you can do is add a content title. This should bring up a boot file dialog box.

 Response.AddHeader("content-disposition", "attachment;filename=xxx.pdf"); 
+1
source

Source: https://habr.com/ru/post/1394015/


All Articles