开发者

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.


I was facing similar issue in some versions of IE and had to set Cache-Control header to make the download working properly:

response.Cache.SetCacheability(HttpCacheability.Private);


try to put a Response.Clear() on top of your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜