SupportSquid
SupportSquid

Reputation: 13

Unable to download files from SSL encrypted webpage in IE8+ - can't modify headers in ASP.NET

I am having a terrible time getting a webpage to work and could really some help. The page is served via IIS 7 with SSL enabled. On it, the user can download an .rtf document or a .zip of multiple .rtf files. This works perfectly fine in FF and Chrome, but as soon as IE is introduced, the end user gets a popup with the following error:

Unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.

Using Fiddler, I can see that the header has Cache-Control set to No-cache and the Pragma is set to no-cache as well. Based on several forums and blogs, this causes IE to disallow downloading of files from the page.

I have tried to change the headers in the ASP.NET codebehind like this:

Response.AppendHeader("Pragma", "public");
Response.AppendHeader("Cache-Control", "must-revalidate, 
    post-check=0, pre-check=0");
Response.AppendHeader("Cache-Control", "public");

and this:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetMaxAge(TimeSpan.FromMinutes(1));
Response.Cache.SetValidUntilExpires(true);

none of which works. The headers are still set as no-cache.

I then tried to add custom header modifications to the website via IIS HTTP Response Headers module, but that isn't working either.

This thread comes close to answering my question but doesn't specify how they were able to rewrite the headers.

I will greatly appreciate any help you folks can give me as I am pulling what's left of my hair out.

Upvotes: 1

Views: 3482

Answers (2)

Travis
Travis

Reputation: 1095

It's already answered, but I figured I'd add another answer that helped me.

Because you're on IIS 7, you can use

Response.Headers.Remove("Pragma")

to remove the Pragma header. The AppendHeader method doesn't override any pre-existing headers, including other Pragma headers, so the "Pragma: no-cache" was still present. Now, with IIS 7, you can remove it.

If you don't have IIS 7, or your local machine is configured to run IIS 6, even though you have IIS 7 available like mine was, you'll get a "This operation requires IIS integrated pipeline mode" exception. Just make sure you're running IIS 7 and you'll be good.

Upvotes: 0

Etch
Etch

Reputation: 3054

Here is a link to the same issue I had. Except I had it with a .pdf. It actually applies to all static file types.

IE8 and client side caching

Upvotes: 1

Related Questions