1

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.

Community
  • 1
  • 1
SupportSquid
  • 13
  • 1
  • 3

2 Answers2

1

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

Community
  • 1
  • 1
Etch
  • 3,044
  • 25
  • 31
  • As you can see from the second block of code posted above, I already tried to use the SetCacheability and SetMaxAge methods in my code. They don't work however. That is my problem. I cannot get the headers to change no matter what I put in the codebehind. – SupportSquid Feb 03 '12 at 20:05
  • I am curious if you have anything in your web.config for your caching, or perhaps an httphandler/httpmodule. Those calls should definitely rewrite the header. Something else is in play here. – Etch Feb 03 '12 at 20:50
  • Thank you for this idea. The site is running on DotNetNuke. The admin had the Host settings set to no-cache for the entire site. I was unaware that DNN did this. Thanks again. – SupportSquid Feb 03 '12 at 22:05
0

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.

Travis
  • 1,044
  • 1
  • 17
  • 36