Response.WriteBinary -> IE 7 security download blocker issue

  • Thread starter Thread starter Earthbound
  • Start date Start date
E

Earthbound

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!
 
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
 
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...
 
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
 
Back
Top