Is it possible to prevent a browser from caching an ASPX page?

 Posted by Poster on 7/1/2008 | Category: ASP.NET Interview questions | Views: 5631
Answer:

Just call SetNoStore on the HttpCachePolicy object exposed through the Response object's Cache property, as demonstrated here:

        <%@ Page Language="C#" %>

<html>
<body>
<%
Response.Cache.SetNoStore ();
Response.Write (DateTime.Now.ToLongTimeString ());
%>
</body>
</html>


SetNoStore works by returning a Cache-Control: private, no-store header in the HTTP response. In this example, it prevents caching of a Web page that shows the current time.


Source: http://groups.msn.com/MumbaiUserGroup/aspnetfaqs2.msnw | Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response