Hello all. I have ASP.NET page with an iframe on it for displaying some pdf reports on this page. When user select the report type from dropdown, I add the needed for report data into the ASP.NET Session and change the attribute "src" of the iframe to .ashx module address which generates the .pdf report. But if Adobe glug-in for viewing .pdf files in browser is not installed, browser proposes to save report file and name of the proposed file is "HandlerName.ashx". But I want to make the browser proposed to save the file with the name "Report.pdf". Can I do this? Are there any workarounds?
+3
A:
Add the following header in your ashx-file:
context.Response.AddHeader("content-disposition", "attachment;filename=PUTYOURFILENAMEHERE.pdf");
context.Response.ContentType = "application/pdf";
Pbirkoff
2010-02-23 11:14:35
+1 for being faster :)
Diadistis
2010-02-23 11:18:58
In this case browser proposes to download file when the Adobe plug-in is installed...
w1z
2010-02-23 11:20:34
+1
A:
Try inline content-disposition, however I have to check this:
Response.ContentType = "application/pdf";
Response.AppendHeader("content-disposition", "inline; filename=" + name );
Mike Chaliy
2010-02-23 11:28:58
Вроде работает, проверил только что. Ты лично меня не знаешь, вместе мы не работали. Я работаю у Бережного. Был на паре твоих докладов на Uneta. CodeContracts интересная штука :)
w1z
2010-02-23 11:53:07
A:
Use
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=Report.PDF");
Response.WriteFile(Server.MapPath("~/YourPath/Report.PDF"));
Response.End();
Priyan R
2010-02-23 11:56:34