alt
Advertisement
Sponsored links
Online Training
Career Series
Exforsys
Exforsys arrow Tutorials arrow ASP.NET 2.0 arrow ASP.NET 2.0 Tutorials : Configuring Page-Level Caching
Site Search


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.


Trackback(0)
Comments (0)add comment

Write comment

busy
 
< Prev   Next >
Exforsys Offers
© 2008 Exforsys.com
Joomla! is Free Software released under the GNU/GPL License.
Page copy protected against web site content infringement by Copyscape