Exforsys.com
 
Home Tutorials ASP.NET 2.0
 

ASP.NET 2.0 Tutorials : Configuring Page-Level Caching

 

ASP.NET 2.0 Tutorials : Configuring Page-Level Caching

In this tutorial you will learn how to configure Page-Level Caching. Page directive and Duration attribute.


Configuring Page-Level Caching

1. In Visual Web Developer, switch to Design view.


2. Drag a Label control to your page, leaving the default name of Label1.


3. Switch to Design view.


4. Double-click the surface.


5. A stubbed out method will be created for you named Page_Load.


6. Add the following highlighted code to the method:


..................void Page_Load(Object sender, System.EventArgs e)
..................{
............................Label1.Text = System.DateTime.Now.ToString();
..................}


7. Press CTRL+F5 to run the page.



8. Close the browser.


Close the browser.

9. Switch to Source view and add the following page directive beneath the @ Page directive:


< % @ OutputCache Duration="15" VaryByParam="none" % >


10. You are setting the page to be cached. The Duration attribute specifies that the page will remain in the cache for 15 seconds.


11. Press CTRL+F5 to run the page again.




12. Refresh the page several times.


13. Since the duration has been set to 15 seconds, the page is only refreshed after the lapse of that time.



Read Next: ASP.NET 2.0 Free Training : Setting Application-Level Caching



 

 

Comments


Dayal said:

  Very good!
July 28, 2006, 8:30 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape