我有一个.aspx页面,它有一个点击按钮打开的按钮.radwindow有一个新页面,内容包括一个按钮onclick,其中创建和下载pdf.I希望pdf打开一个新的选项卡或窗口,所以我更改了代码更改为内联的附件
Hashtable deviceInfo = new Hashtable();
deviceInfo.Add("FontEmbedding", "Subset");
deviceInfo.Add("DocumentTitle", String.Format("TrackitManager - {0}", reportToExport.DocumentName));
deviceInfo.Add("DocumentAuthor", "Trackit Systems Pty Ltd");
ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, deviceInfo);
if (String.IsNullOrEmpty(filename))
filename = result.DocumentName;
context.Response.Clear();
context.Response.ContentType = result.MimeType;
context.Response.Cache.SetCacheability(HttpCacheability.Private);
context.Response.Expires = -1;
context.Response.Buffer = true;
//context.Response.TransmitFile("~/Handlers/EnrollmentPDF.ashx");
context.Response.AppendHeader("Content-Disposition", string.Format("attachment; filename=\"{0}.pdf\"", filename));
context.Response.BinaryWrite(result.DocumentBytes);
context.Response.End();
但这是在radwindow本身内打开pdf。我希望它在新窗口中打开,但在radwindow之外。
答案 0 :(得分:0)
你必须提供正确的标题和mimeType来告诉浏览器下载文件 为此你只需要添加这一行来替换:
context.Response.ContentType = result.MimeType;
这一行:
Response.ContentType = "application/octectstream";