Response.WriteBinary -> IE 7 security download blocker issue

Discussion in 'ASP .Net' started by Earthbound, Apr 25, 2008.

  1. Earthbound

    Earthbound Guest

    Hello,

    I have a a web page where users can choose, via links, in what format they
    want to see results in: PDF, XPS, HTML, or downloadable ZIP file.
    I do not have any issues with any of the processes other than the ZIP file
    and that problem occures in the Browser, IE 7.
    This problem has been tested with IE 7 on Vista x64, Vista x86, XP x64 and
    XP x86.
    Os here doesn't seem to be the issue as this problem occures in all these
    versions of IE 7.

    NOTE: This is NOT a problem with Firefox as it is working there as expected.

    The page I have uses a Javascript postback (AJAX) to notify itself of which
    link was selected. The post back then does a Response.Redirect to the page
    responsible for creating the document or download in this case that the user
    wants.

    The PDF and ZIP process are basically identical to each other, other that
    the file type it delivers to the client browser.

    The issues is that when the user selects the ZIP download link the IE 7
    Browser displays the security bar giving the download warning bar at the top
    of the page. This requires the user to confirm that they are trying to
    download a file by clicking on the ".. Click her for options" and then
    "Download this file" from the menu.
    This is very normal. However the download never occures, it is as if IE 7
    abandons it and just refresh the page.

    If the user subseqently clicks on the link again while still at the page the
    down happens WITHOUT the security bar interferance and the user gets the
    standard File Download Dialog box. The download then occures successfully
    and the ZIP file. It is worth noting that the zip file and it's contents are
    not corrupt or otherwise displaying issues.

    Here is what the basic code looks like in my ASP.net page, again note that
    this code is identical in my PDF download page and it works without the
    problem discribed above.
    (vista x64 VS08 is my current build/test environment)

    HttpResponse r = this.Context.Response;
    r.ClearContent();
    r.ClearHeaders();
    r.Clear();
    r.AppendHeader("Content-Type", "application/zip");
    r.AppendHeader("Content-Length", buffer.Length.ToString());
    r.AppendHeader("Content-Disposition", "attachment; filename=" +
    FileName.ToString() + ".zip");
    r.BinaryWrite(buffer);
    r.Flush();
    r.End();

    NOTE: Have tried every many variations of the Content-Type using one or more
    of them in my testing which made no difference as far as the discribed
    problem.

    I have spent several hours trying to find a way to resolve this and have
    researched many forums and KB's to find an answer but, to with no luck

    PLEASE some point me to something that can help. I am at my wits end in
    trying to find a solution, without having to resort to telling all of our
    customer the we prefer that they use Firefox at our web site in order to
    overcome this issue with IE 7.

    I would really like to understand why the PDF file downsloads after the
    security bar and the Zip file does not!

    Your help is greatly appreciated.

    MANY MANY Thanks!
    Earthbound, Apr 25, 2008
    #1
    1. Advertising

  2. Re: Response.WriteBinary -> IE 7 security download blocker issue

    On Apr 25, 9:09 pm, "Earthbound" <> wrote:
    > Hello,
    >
    > I have a a web page where users can choose, via links, in what format they
    > want to see results in: PDF, XPS, HTML, or downloadable ZIP file.
    > I do not have any issues with any of the processes other than the ZIP file
    > and that problem occures in the Browser, IE 7.
    > This problem has been tested with IE 7 on Vista x64, Vista x86, XP x64 and
    > XP x86.
    > Os here doesn't seem to be the issue as this problem occures in all these
    > versions of IE 7.
    >
    > NOTE: This is NOT a problem with Firefox as it is working there as expected.
    >
    > The page I have uses a Javascript postback (AJAX) to notify itself of which
    > link was selected. The post back then does a Response.Redirect to the page
    > responsible for creating the document or download in this case that the user
    > wants.
    >
    > The PDF and ZIP process are basically identical to each other, other that
    > the file type it delivers to the client browser.
    >
    > The issues is that when the user selects the ZIP download link the IE 7
    > Browser displays the security bar giving the download warning bar at the top
    > of the page. This requires the user to confirm that they are trying to
    > download a file by clicking on the ".. Click her for options" and then
    > "Download this file" from the menu.
    > This is very normal. However the download never occures, it is as if IE 7
    > abandons it and just refresh the page.
    >
    > If the user subseqently clicks on the link again while still at the page the
    > down happens WITHOUT the security bar interferance and the user gets the
    > standard File Download Dialog box. The download then occures successfully
    > and the ZIP file. It is worth noting that the zip file and it's contents are
    > not corrupt or otherwise displaying issues.
    >
    > Here is what the basic code looks like in my ASP.net page, again note that
    > this code is identical in my PDF download page and it works without the
    > problem discribed above.
    > (vista x64 VS08 is my current build/test environment)
    >
    >     HttpResponse r = this.Context.Response;
    >     r.ClearContent();
    >     r.ClearHeaders();
    >     r.Clear();
    >     r.AppendHeader("Content-Type", "application/zip");
    >     r.AppendHeader("Content-Length", buffer.Length.ToString());
    >     r.AppendHeader("Content-Disposition", "attachment; filename=" +
    > FileName.ToString() + ".zip");
    >     r.BinaryWrite(buffer);
    >     r.Flush();
    >     r.End();
    >
    > NOTE: Have tried every many variations of the Content-Type using one or more
    > of them in my testing which made no difference as far as the discribed
    > problem.
    >
    > I have spent several hours trying to find a way to resolve this and have
    > researched many forums and KB's to find an answer but, to with no luck
    >
    > PLEASE some point me to something that can help. I am at my wits end in
    > trying to find a solution, without having to resort to telling all of our
    > customer the we prefer that they use Firefox at our web site in order to
    > overcome this issue with IE 7.
    >
    > I would really like to understand why the PDF file downsloads after the
    > security bar and the Zip file does not!
    >
    > Your help is greatly appreciated.
    >
    > MANY MANY Thanks!


    Instead of "application/zip" in r.AppendHeader("Content-Type",
    "application/zip"); try either

    application/x-compressed
    application/x-zip-compressed
    application/x-gzip-compressed

    http://msdn2.microsoft.com/en-us/library/ms775147.aspx
    Alexey Smirnov, Apr 25, 2008
    #2
    1. Advertising

  3. Re: Response.WriteBinary -> IE 7 security download blocker issue

    On Apr 25, 9:25 pm, Alexey Smirnov <> wrote:
    > On Apr 25, 9:09 pm, "Earthbound" <> wrote:
    >
    >
    >
    >
    >
    > > Hello,

    >
    > > I have a a web page where users can choose, via links, in what format they
    > > want to see results in: PDF, XPS, HTML, or downloadable ZIP file.
    > > I do not have any issues with any of the processes other than the ZIP file
    > > and that problem occures in the Browser, IE 7.
    > > This problem has been tested with IE 7 on Vista x64, Vista x86, XP x64 and
    > > XP x86.
    > > Os here doesn't seem to be the issue as this problem occures in all these
    > > versions of IE 7.

    >
    > > NOTE: This is NOT a problem with Firefox as it is working there as expected.

    >
    > > The page I have uses a Javascript postback (AJAX) to notify itself of which
    > > link was selected. The post back then does a Response.Redirect to the page
    > > responsible for creating the document or download in this case that the user
    > > wants.

    >
    > > The PDF and ZIP process are basically identical to each other, other that
    > > the file type it delivers to the client browser.

    >
    > > The issues is that when the user selects the ZIP download link the IE 7
    > > Browser displays the security bar giving the download warning bar at the top
    > > of the page. This requires the user to confirm that they are trying to
    > > download a file by clicking on the ".. Click her for options" and then
    > > "Download this file" from the menu.
    > > This is very normal. However the download never occures, it is as if IE 7
    > > abandons it and just refresh the page.

    >
    > > If the user subseqently clicks on the link again while still at the page the
    > > down happens WITHOUT the security bar interferance and the user gets the
    > > standard File Download Dialog box. The download then occures successfully
    > > and the ZIP file. It is worth noting that the zip file and it's contents are
    > > not corrupt or otherwise displaying issues.

    >
    > > Here is what the basic code looks like in my ASP.net page, again note that
    > > this code is identical in my PDF download page and it works without the
    > > problem discribed above.
    > > (vista x64 VS08 is my current build/test environment)

    >
    > >     HttpResponse r = this.Context.Response;
    > >     r.ClearContent();
    > >     r.ClearHeaders();
    > >     r.Clear();
    > >     r.AppendHeader("Content-Type", "application/zip");
    > >     r.AppendHeader("Content-Length", buffer.Length.ToString());
    > >     r.AppendHeader("Content-Disposition", "attachment; filename=" +
    > > FileName.ToString() + ".zip");
    > >     r.BinaryWrite(buffer);
    > >     r.Flush();
    > >     r.End();

    >
    > > NOTE: Have tried every many variations of the Content-Type using one or more
    > > of them in my testing which made no difference as far as the discribed
    > > problem.

    >
    > > I have spent several hours trying to find a way to resolve this and have
    > > researched many forums and KB's to find an answer but, to with no luck

    >
    > > PLEASE some point me to something that can help. I am at my wits end in
    > > trying to find a solution, without having to resort to telling all of our
    > > customer the we prefer that they use Firefox at our web site in order to
    > > overcome this issue with IE 7.

    >
    > > I would really like to understand why the PDF file downsloads after the
    > > security bar and the Zip file does not!

    >
    > > Your help is greatly appreciated.

    >
    > > MANY MANY Thanks!

    >
    > Instead of  "application/zip" in r.AppendHeader("Content-Type",
    > "application/zip"); try either
    >
    > application/x-compressed
    > application/x-zip-compressed
    > application/x-gzip-compressed
    >
    > http://msdn2.microsoft.com/en-us/library/ms775147.aspx


    either... or application/force-download or application/octet-stream...
    Alexey Smirnov, Apr 25, 2008
    #3
  4. Earthbound

    Earthbound Guest

    Re: Response.WriteBinary -> IE 7 security download blocker issue

    "Alexey Smirnov" <> wrote in message
    news:...
    On Apr 25, 9:09 pm, "Earthbound" <> wrote:
    > Hello,
    >
    > I have a a web page where users can choose, via links, in what format they
    > want to see results in: PDF, XPS, HTML, or downloadable ZIP file.
    > I do not have any issues with any of the processes other than the ZIP file
    > and that problem occures in the Browser, IE 7.
    > This problem has been tested with IE 7 on Vista x64, Vista x86, XP x64 and
    > XP x86.
    > Os here doesn't seem to be the issue as this problem occures in all these
    > versions of IE 7.
    >
    > NOTE: This is NOT a problem with Firefox as it is working there as
    > expected.
    >
    > The page I have uses a Javascript postback (AJAX) to notify itself of
    > which
    > link was selected. The post back then does a Response.Redirect to the page
    > responsible for creating the document or download in this case that the
    > user
    > wants.
    >
    > The PDF and ZIP process are basically identical to each other, other that
    > the file type it delivers to the client browser.
    >
    > The issues is that when the user selects the ZIP download link the IE 7
    > Browser displays the security bar giving the download warning bar at the
    > top
    > of the page. This requires the user to confirm that they are trying to
    > download a file by clicking on the ".. Click her for options" and then
    > "Download this file" from the menu.
    > This is very normal. However the download never occures, it is as if IE 7
    > abandons it and just refresh the page.
    >
    > If the user subseqently clicks on the link again while still at the page
    > the
    > down happens WITHOUT the security bar interferance and the user gets the
    > standard File Download Dialog box. The download then occures successfully
    > and the ZIP file. It is worth noting that the zip file and it's contents
    > are
    > not corrupt or otherwise displaying issues.
    >
    > Here is what the basic code looks like in my ASP.net page, again note that
    > this code is identical in my PDF download page and it works without the
    > problem discribed above.
    > (vista x64 VS08 is my current build/test environment)
    >
    > HttpResponse r = this.Context.Response;
    > r.ClearContent();
    > r.ClearHeaders();
    > r.Clear();
    > r.AppendHeader("Content-Type", "application/zip");
    > r.AppendHeader("Content-Length", buffer.Length.ToString());
    > r.AppendHeader("Content-Disposition", "attachment; filename=" +
    > FileName.ToString() + ".zip");
    > r.BinaryWrite(buffer);
    > r.Flush();
    > r.End();
    >
    > NOTE: Have tried every many variations of the Content-Type using one or
    > more
    > of them in my testing which made no difference as far as the discribed
    > problem.
    >
    > I have spent several hours trying to find a way to resolve this and have
    > researched many forums and KB's to find an answer but, to with no luck
    >
    > PLEASE some point me to something that can help. I am at my wits end in
    > trying to find a solution, without having to resort to telling all of our
    > customer the we prefer that they use Firefox at our web site in order to
    > overcome this issue with IE 7.
    >
    > I would really like to understand why the PDF file downsloads after the
    > security bar and the Zip file does not!
    >
    > Your help is greatly appreciated.
    >
    > MANY MANY Thanks!


    Instead of "application/zip" in r.AppendHeader("Content-Type",
    "application/zip"); try either

    application/x-compressed
    application/x-zip-compressed
    application/x-gzip-compressed

    http://msdn2.microsoft.com/en-us/library/ms775147.aspx


    Thank you Alexey, however as I indicated in my message I have tried every
    flavor of of Content-Type including those that you have provided and no
    changes in the problem. Again tested on all those diffent OS'es with IE 7.
    This one is a bloody stumpper...
    Earthbound, Apr 25, 2008
    #4
  5. Re: Response.WriteBinary -> IE 7 security download blocker issue

    On Apr 25, 9:41 pm, "Earthbound" <> wrote:
    > "Alexey Smirnov" <> wrote in message
    >
    > news:...
    > On Apr 25, 9:09 pm, "Earthbound" <> wrote:
    >
    >
    >
    >
    >
    > > Hello,

    >
    > > I have a a web page where users can choose, via links, in what format they
    > > want to see results in: PDF, XPS, HTML, or downloadable ZIP file.
    > > I do not have any issues with any of the processes other than the ZIP file
    > > and that problem occures in the Browser, IE 7.
    > > This problem has been tested with IE 7 on Vista x64, Vista x86, XP x64 and
    > > XP x86.
    > > Os here doesn't seem to be the issue as this problem occures in all these
    > > versions of IE 7.

    >
    > > NOTE: This is NOT a problem with Firefox as it is working there as
    > > expected.

    >
    > > The page I have uses a Javascript postback (AJAX) to notify itself of
    > > which
    > > link was selected. The post back then does a Response.Redirect to the page
    > > responsible for creating the document or download in this case that the
    > > user
    > > wants.

    >
    > > The PDF and ZIP process are basically identical to each other, other that
    > > the file type it delivers to the client browser.

    >
    > > The issues is that when the user selects the ZIP download link the IE 7
    > > Browser displays the security bar giving the download warning bar at the
    > > top
    > > of the page. This requires the user to confirm that they are trying to
    > > download a file by clicking on the ".. Click her for options" and then
    > > "Download this file" from the menu.
    > > This is very normal. However the download never occures, it is as if IE 7
    > > abandons it and just refresh the page.

    >
    > > If the user subseqently clicks on the link again while still at the page
    > > the
    > > down happens WITHOUT the security bar interferance and the user gets the
    > > standard File Download Dialog box. The download then occures successfully
    > > and the ZIP file. It is worth noting that the zip file and it's contents
    > > are
    > > not corrupt or otherwise displaying issues.

    >
    > > Here is what the basic code looks like in my ASP.net page, again note that
    > > this code is identical in my PDF download page and it works without the
    > > problem discribed above.
    > > (vista x64 VS08 is my current build/test environment)

    >
    > > HttpResponse r = this.Context.Response;
    > > r.ClearContent();
    > > r.ClearHeaders();
    > > r.Clear();
    > > r.AppendHeader("Content-Type", "application/zip");
    > > r.AppendHeader("Content-Length", buffer.Length.ToString());
    > > r.AppendHeader("Content-Disposition", "attachment; filename=" +
    > > FileName.ToString() + ".zip");
    > > r.BinaryWrite(buffer);
    > > r.Flush();
    > > r.End();

    >
    > > NOTE: Have tried every many variations of the Content-Type using one or
    > > more
    > > of them in my testing which made no difference as far as the discribed
    > > problem.

    >
    > > I have spent several hours trying to find a way to resolve this and have
    > > researched many forums and KB's to find an answer but, to with no luck

    >
    > > PLEASE some point me to something that can help. I am at my wits end in
    > > trying to find a solution, without having to resort to telling all of our
    > > customer the we prefer that they use Firefox at our web site in order to
    > > overcome this issue with IE 7.

    >
    > > I would really like to understand why the PDF file downsloads after the
    > > security bar and the Zip file does not!

    >
    > > Your help is greatly appreciated.

    >
    > > MANY MANY Thanks!

    >
    > Instead of  "application/zip" in r.AppendHeader("Content-Type",
    > "application/zip"); try either
    >
    > application/x-compressed
    > application/x-zip-compressed
    > application/x-gzip-compressed
    >
    > http://msdn2.microsoft.com/en-us/library/ms775147.aspx
    >
    > Thank you Alexey, however as I indicated in my message I have tried every
    > flavor of  of Content-Type including those that you have provided and no
    > changes in the problem. Again tested on all those diffent OS'es with IE 7.
    > This one is a bloody stumpper...- Hide quoted text -
    >
    > - Show quoted text -


    It seems that the problem was in missing Content-Encoding

    using (System.IO.FileStream fs = new System.IO.FileStream(
    @"C:\Temp\Test.zip",
    System.IO.FileMode.Open, FileAccess.Read))
    {
    byte[] buffer = new byte[(int)fs.Length];
    fs.Read(buffer, 0, (int)fs.Length);

    HttpResponse r = this.Context.Response;
    r.ClearContent();
    r.ClearHeaders();
    r.Clear();
    r.AppendHeader("Content-Type", "application/octet-stream");
    //r.AppendHeader("Content-Length", buffer.Length.ToString());
    r.AppendHeader("Content-Encoding", "gzip");
    r.AppendHeader("Content-Disposition", "attachment;
    filename=Test.zip");
    r.BinaryWrite(buffer);
    r.Flush();
    r.End();
    }

    In this case browser get following response from the server

    HTTP/1.1 200 OK
    ...
    Content-Encoding: gzip
    Content-Disposition: attachment; filename=test.zip
    Content-Type: application/octet-stream
    Alexey Smirnov, Apr 25, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Adam B

    SSL Response.WriteBinary()

    Adam B, Dec 4, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,043
    Adam B
    Dec 4, 2003
  2. Simon Segal

    XP SP2 Popup Blocker & Frames

    Simon Segal, Nov 8, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    366
    Simon Segal
    Nov 8, 2004
  3. Jachu

    new windows popup blocker

    Jachu, May 13, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    854
    Jachu
    May 13, 2005
  4. Adam B

    SSL Response.WriteBinary()

    Adam B, Dec 4, 2003, in forum: ASP .Net Security
    Replies:
    0
    Views:
    108
    Adam B
    Dec 4, 2003
  5. Adam B

    SSL Response.WriteBinary problem

    Adam B, Dec 4, 2003, in forum: ASP General
    Replies:
    1
    Views:
    160
    Ray at
    Dec 4, 2003
Loading...

Share This Page