开发者

Response.BinaryWrite not working with IE6

I'm using the following C# code in some ASP.NET to开发者_StackOverflow中文版 send a file to the browser:

Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=" + myFileName);
Response.BinaryWrite(myContent);
Response.End();
Response.Close();

It works well with WebDev.WebServer and IIS7, under IE7-8, FF3-4 and Chrome. But not under IE6. I can't see why it can be a browser related issue...


Try adding content-length header:

Response.AddHeader("content-length", myContent.Length.ToString());

Edit: another one that might be required is content-type:

Response.AddHeader("content-type", "type here");


instead of BinaryWrite, use TransmitFile. see example here


Thank you all, here is the answer: it was due to Ajax in the page, and the Ajax request wasn't disabled as expected.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜