简体   繁体   中英

Http response file download not working in Internet explorer and chrome (C#, Asp.net)

I write a file download method to download file from server to client machine in C# asp.net

I wrote the following code:

Response.ContentType = ReturnExtension(System.IO.Path.GetExtension(file.Name));

                    Response.AppendHeader("Content-Disposition", "attachment; filename=" + file.Name);

                    Response.TransmitFile(strRequest);

                    Response.End();

This will work fine in Firefox and Chrome, but not in IE.

在某些版本的IE中,我遇到了类似的问题,必须设置Cache-Control标头才能使下载正常进行:

response.Cache.SetCacheability(HttpCacheability.Private);

尝试将Response.Clear()放在代码之上。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM