ASP.NET 生成的excel文件推送到手机客户端后内容变成了网页源码
我用C#在IIS服务器端生成excel并推送到客户端,在PC客户端下载后得到的是正确的excel文件和内容,但在手机的浏览器上(下载时,虽然也显示是excel的文件,但下...
我用C#在IIS服务器端生成excel并推送到客户端,在PC客户端下载后得到的是正确的excel文件和内容,但在手机的浏览器上(下载时,虽然也显示是excel的文件,但下载到的文件打开后内容是网页的源代码。请教大家之前有遇到过这样的情况吗?
ASP.NET 4.0.30319.34237
下附推送部分的代码
FileStream stream = new FileStream(ExcelFileName, FileMode.Open);
long Filesize = stream.Length;
byte[] Buffer = new byte[(int)Filesize];
stream.Read(Buffer, 0, (int)Filesize);
stream.Close();
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(Path.GetFileName(ExcelFileName)));
Response.AddHeader("Content-Length", Filesize.ToString());
Response.ContentType = "application/ms-excel";
Response.BinaryWrite(Buffer);
Response.Flush();
Response.Close();
Response.End(); 展开
ASP.NET 4.0.30319.34237
下附推送部分的代码
FileStream stream = new FileStream(ExcelFileName, FileMode.Open);
long Filesize = stream.Length;
byte[] Buffer = new byte[(int)Filesize];
stream.Read(Buffer, 0, (int)Filesize);
stream.Close();
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(Path.GetFileName(ExcelFileName)));
Response.AddHeader("Content-Length", Filesize.ToString());
Response.ContentType = "application/ms-excel";
Response.BinaryWrite(Buffer);
Response.Flush();
Response.Close();
Response.End(); 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询