after a long search on the net I did not find a solution how I can do when I click on a document starts its download in the browser ,I need this in my application .net core
Asked
Active
Viewed 48 times
-2
-
Does this answer your question? [Force browser to download PDF document instead of opening it](https://stackoverflow.com/questions/8590543/force-browser-to-download-pdf-document-instead-of-opening-it) – Mohammad Barbast Jul 12 '20 at 12:42
1 Answers
0
You just need to:
first, set your response mime type:
Response.Headers.Add("Content-Type", "application/pdf"); //for example
second, set following header as a dictate to browsers to download file:
Response.Headers.Add("Content-Disposition", "attachment; filename=foo.pdf"); //for example

Mohammad Barbast
- 1,753
- 3
- 17
- 28