<% Response.CacheControl = "no-cache" %>

  • Thread starter Thread starter Jason Huang
  • Start date Start date
J

Jason Huang

Hi,

Kind of spending too much time on the no-cache issue and found out something
like <% Response.CacheControl = "no-cache" %>.
In my ASP.Net, a C# .aspx file, where do I put the <% Response.CacheControl
= "no-cache" %>?
Is this enough to fix the Caching bug?
Thanks for help.

Jason
 
Hi,

I think so, I have never do it that way, I use this line in the code behind:

Response.Cache.SetCacheability(HttpCacheability.NoCache);


cheers,
 
Jason said:
Hi,

Kind of spending too much time on the no-cache issue and found out
something like <% Response.CacheControl = "no-cache" %>. In my
ASP.Net, a C# .aspx file, where do I put the <%
Response.CacheControl = "no-cache" %>? Is this enough to fix the
Caching bug? Thanks for help.

Um... caching bug?

Anyway, either set the OutputCache directive on your page(s)

<%@ OutputCache Location="None" %>

or set the Cache property of the HttpResponse in your code-behind class:

Response.Cache.SetCacheability(HttpCacheability.NoCache);

(which is equivalent to the directive shown above)

Cheers,
 
Back
Top