Link to home
Start Free TrialLog in
Avatar of Adnan
AdnanFlag for Norway

asked on

HTTPResponse output stream write file to Word failed to download in IE 9....

Hi

When i try to write a byte array to a .docx file in IE 9 , it failes to download, and when i retry it opens up a word document with error message saying that the file is broken or corrupt..... And if i try to open it in FireFox every thing workes fine, so whats the problom with IE 9? User generated image
private void ReturnDoc(byte[] doc, string filename)
        {
            HttpResponse resp = HttpContext.Current.Response;

            resp.Clear();
            resp.ClearContent();
            resp.ClearHeaders();
            resp.Buffer = true;

            resp.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
            resp.AddHeader("content-disposition", "attachment;filename=" + filename);
            resp.AddHeader("Content-Length", doc.Length.ToString());

            resp.OutputStream.Write(doc, 0, (int)doc.Length);
            resp.Flush();
           
            // resp.BinaryWrite(doc);
            resp.Close();

            HttpContext.Current.ApplicationInstance.CompleteRequest();

        }

Open in new window

970214cbbe.jpg
ASKER CERTIFIED SOLUTION
Avatar of Adnan
Adnan
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Adnan

ASKER

I turned 'Do not save encrypted pages to disk' option is turned off and every thing is working now....STUPID IE
Avatar of Adnan

ASKER

Probom fixed after tairing my hair of in 2 days