mpp.myPDF(Response.OutputStream); // PdfDocument...
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
【HTTP】
IE,Firefox,Chrome:好的
【HTTPS】
IE 9,10,11:好的 Firefox:好的 Chrome:好的但
IE 6,7,8 = X ......它显示错误
Internet Explorer无法打开此Internet站点 请求的网站不可用或无法找到。
protected void OnPrintClick(object sender, EventArgs e)
{
if ((Request.Browser.Browser == "IE") && (Request.Browser.MajorVersion < 9))
{
Response.ExpiresAbsolute = DateTime.Now;
Response.Expires = -1441;
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.AddHeader("Pragma", "no-store");
Response.AddHeader("cache-control", "no-cache");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoServerCaching();
Response.Clear();
Response.Expires = 0;
Response.Buffer = true;
Response.HeaderEncoding = System.Text.Encoding.Default;
}
//↑
// I try to add these code are invalid....【Https】 IE 6、7、8.... X
mpp.myPDF(Response.OutputStream); // PdfDocument...
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
}
我们如何解决这个问题?
答案 0 :(得分:0)
在尝试流式传输到客户端/浏览器之前,请考虑将ContentType
设置为"application/pdf"
并清除所有内容:
Response.Buffer = false;
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename");
mpp.myPDF(Response.OutputStream); // PdfDocument...
//could also consider:
//Response.TransmitFile("path to document");
//Response.BinaryWrite((byte[]) stream);
Response.End()