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

Answers were Sorted based on User's Feedback



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

Answer / manoj

Write this code in the Page load event of the code behind :-

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Is This Answer Correct ?    5 Yes 2 No

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

Answer / swapna

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

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

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


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.

Is This Answer Correct ?    3 Yes 1 No

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

Answer / surendra singh

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.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

With out Web.config can we executes the application?

10 Answers   Valtech,


What is a pixel url?

0 Answers  


How do you change the session time-out value?

0 Answers   TryTechnicals Pvt Ltd,


How to authenticate users using Web.Config ?

1 Answers   Accenture,


Define the term Web Garden?

0 Answers   Sans Pareil IT Services,






What is Dynamic Web and discuss its usage with the help of real life examples?

0 Answers   Huawei,


Asp pages that worked pefectly on windows 2000 server and iis 5.0 do not work on windows 2003 server with iis 6.0. Asp.net pages work fine. Why?

0 Answers  


Explain the main function of razor in asp.net? : asp.net mvc

0 Answers  


How do you declare static variable?

0 Answers  


What is the mvc model?

0 Answers  


What methods are fired during the page load? Init()

0 Answers  


what is Impersonation

3 Answers   Alliance One, Task Informatics,


Categories