[英]Http response file download not working in Internet explorer and chrome (C#, Asp.net)
我编写了一种文件下载方法,将文件从服务器下载到C#asp.net中的客户端计算机
我写了以下代码:
Response.ContentType = ReturnExtension(System.IO.Path.GetExtension(file.Name));
Response.AppendHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.TransmitFile(strRequest);
Response.End();
在Firefox和Chrome中可以正常使用,但在IE中则不能。
在某些版本的IE中,我遇到了类似的问题,必须设置Cache-Control标头才能使下载正常进行:
response.Cache.SetCacheability(HttpCacheability.Private);
尝试将Response.Clear()
放在代码之上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.