Asp.net pdf下载(无法在ie11下载pdf文件) [英] Asp.net pdf download (not able to download a pdf file in ie11)

查看:75
本文介绍了Asp.net pdf下载(无法在ie11下载pdf文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我给用户下载文件的链接,并在Chrome中工作正常,但它不能在IE11中工作,这个问题只有几个文件(大小超过1MB)。文件我正在扔数据库。

有人可以帮我吗?

以下是代码示例:



 Response.Clear(); 
Response.Buffer = true ;
Response.ClearContent();
Response.ClearHeaders();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.AddHeader( content-disposition String .Format( attachment; filename = {0},drAttchmentInfo [ FileName]。ToString()));
Response.ContentType = application / + drAttchmentInfo [ DocumentType]。ToString(); Response.BinaryWrite(( byte [])drAttchmentInfo [ 文件]);
// Response.End();
Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.Close();

解决方案

我没有为您提供解决方案 - 但我遇到了类似的问题,似乎只是刚刚开发的IE11最近更新(不确定何时)。我的代码在以前的IE版本中运行,在Chrome中运行良好。它将一些数据写入内存流,然后使用BinaryWrite写入响应。这是挂起的(数据量非常小 - 几百字节)



 使用(MemoryStream stream =  new  MemoryStream())
{
使用(XmlTextWriter writer = new XmlTextWriter(stream,Encoding.UTF8))
{
// 写一些东西
}
byte [ ] content = stream.ToArray();
Response.AddHeader( Content-disposition attachment; filename = AuthenticatedLicense.lic);
Response.ContentType = application / octet-stream;
Response.BinaryWrite(content);
Response.End();
}





我所看到的一切都表明这是正确的做事方式 - 但似乎IE11已经坏了。


i have one application where i am giving a link to user to download files and that is working fine in chrome but its not working in IE11 and this problem is with only few files(which has size more than 1MB). files i am getting threw database.
can anyone help me on this?
below is the code sample:

Response.Clear();
Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", drAttchmentInfo["FileName"].ToString()));
Response.ContentType = "application/" + drAttchmentInfo["DocumentType"].ToString();                                Response.BinaryWrite((byte[])drAttchmentInfo["Document"]);
//Response.End();                                
Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.Close();

解决方案

I haven't got a solution for you - but I'm experiencing a similar issue which seems to have only just developed with a recent update to IE11 (not sure when). My code was working in previous version of IE and works fine in Chrome. It writes out some data to a memory stream that it then uses BinaryWrite to write to the response. This is now hanging (an the amount of data is very small - a few hundred bytes)

using (MemoryStream stream = new MemoryStream())
{
    using (XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8))
    {
        // write some stuff
    }
    byte[] content = stream.ToArray();
    Response.AddHeader("Content-disposition", "attachment; filename=AuthenticatedLicense.lic");
    Response.ContentType = "application/octet-stream";
    Response.BinaryWrite(content);
    Response.End();
}



Everything I have seen indicates that this is the correct way of doing things - but it seems IE11 is broken.


这篇关于Asp.net pdf下载(无法在ie11下载pdf文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆