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

what is generics?

2 Answers   Microsoft,


Will the asp.net validators run in server side or client side? How do you do client-side validation in .net? How to disable validator control by client side javascript?

0 Answers  


What are session state modes in asp.net?

0 Answers  


Define static constructor?

0 Answers  


Explain global assembly cache.

0 Answers  






Is there any limit for query string? Means what is the maximum size?

0 Answers  


What is the use of HttpHandlers? When to use this?

0 Answers   Wipro,


What are different types of api?

0 Answers  


What are the Types of chaching. How to implement caching

0 Answers   Microsoft,


What are the security types in asp.net?

0 Answers  


How can you identify that the page is post back?

0 Answers  


main difference between asp.net2.0,asp.net1.1,asp.net1.0

15 Answers   Inflexion, Infosys, iSoft, Microsoft, Prakruthi,


Categories