5

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?

4

3 に答える 3

7

ashx ファイルに次のヘッダーを追加します。

context.Response.AddHeader("content-disposition", "attachment;filename=PUTYOURFILENAMEHERE.pdf");
context.Response.ContentType = "application/pdf";
于 2010-02-23T11:14:35.660 に答える
4

インラインの content-disposition を試してください。ただし、これを確認する必要があります。

Response.ContentType = "application/pdf"; 
Response.AppendHeader("content-disposition", "inline; filename=" + name ); 
于 2010-02-23T11:28:58.990 に答える
3
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();
于 2010-02-23T11:56:34.163 に答える