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

Posted on 2011-10-26
Last Modified: 2012-06-27

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? This message box is saying that: Found unreadable content in file "Saksliste". Do you want to reproduce the document...bla bla...
private void ReturnDoc(byte[] doc, string filename)
            HttpResponse resp = HttpContext.Current.Response;

            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.BinaryWrite(doc);



Open in new window

Question by:Adnan

    Accepted Solution

    What iam trying to do is  I am streaming a Word document to the browser, This works in all browsers over HTTP and all browsers except IE over HTTPS.....!!

    I found this articale when i google:
    And here they are saying that the problom is around allowing  method of streaming PDF, Excel or Word documents when the 'Do not save encrypted pages to disk' option is turned on in the IE/browser...?!

    Author Comment

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

    Author Closing Comment

    Probom fixed after tairing my hair of in 2 days

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now