2

I have an asp.net webform that displays a PDF, Stack helped me with that How to display a pdf file in asp.net web-form. My problem now is that this seems to cache the PDF files locally. I need them to be freshly retrieved from the server each time they're called to account for updates.

The PDF files are stored in a network shared folder.

How can I prevent these files from caching in code (or do I have to do from IIS or the shared folder)?

Community
  • 1
  • 1
MAW74656
  • 3,449
  • 21
  • 71
  • 118

1 Answers1

1

Did you try with below code.

protected void Page_Load(object sender, EventArgs e)
{
    Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
}
Pankaj
  • 9,749
  • 32
  • 139
  • 283
  • 1
    If you are using .NET 3.5 or higher add `Response.Cache.SetCacheability(HttpCacheability.NoCache);` also. – JamieSee Feb 17 '12 at 21:58
  • What will so in terms of any difference between these two statements in any context...? Your ideas are highly appreciated.. – Pankaj Feb 18 '12 at 05:21
  • @JamieSee -This isn't doing the trick. I have a user complaining about this who is using Google Chrome browser. Is there anything additional/different I can do to improve this? – MAW74656 Apr 25 '12 at 16:39
  • Looks like it's a bug in Chrome. See http://code.google.com/p/chromium/issues/detail?id=28035 for more information. – JamieSee Apr 25 '12 at 17:56