Tips Station Asp.net Article Seo Articles
Tutorials Code Samples
›  Home
›  Mission
›  About us
›  Contact Us
›  Feedback
›  Terms & Condition
Asp Articles
IT Solutions
 
› ASP.NET

› Programming Tips

› Ajax

› Asp

› ADO.NET

› Databases

› SEO

› CSS And Designing

› Php

 
Most Viewed Articles
 
› Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

› Change theme dynamically without page refresh in ASP.NET

› Install AJAX On Machines Running Visual Studio 2005

› Creating Pretty Popups Using AJAX

› Simple ASP Image Resize Function

› SQL Server Performance Counters

› ASP.Net Interview Questions And Their Answers

› Encode Url using ASP

› Difference Between DataGrid and GridView in Asp.Net

› Select Specific Value WithIn Drop Down List Or Radio Button List

more...
 
 
Home> ASP.NET
 
Cache Data within your Application - Asp.Net
 

An example of how you can cache data within your application.

ASP.NET provides an OutputCache method that allows you to cache a page on the server so that future requests don't have to recreate the page. However, there may be times when you want to cache something programmatically so that you can use that object across multiple page. Luckily, this is very easy to do and here's a simple example that shows how to cache a DataTable for 1 hour:

 Public Function GetData() As DataTable  
   
    ' Create a new DataTable and set it to the cached version  
    Dim dt As New DataTable  
    dt = HttpContext.Current.Cache.Get("MyData")  
   
    ' Check if the DataTable exists in the cache  
    If dt Is Nothing Then  
         ' Place your code to get your data here  
         MyDataTable = ...  
   
         ' Add the DataTable to the cache  
         HttpContext.Current.Cache.Insert("MyData", MyDataTable, Nothing, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration)  
   
         'Return the DataTable  
         Return MyDataTable  
    Else  
        ' Return the cached version  
        Return dt  
    End If  
   
 End Function 

 
 
Vrp Technologies
 
Serversea Hosting
 
 
Latest Articles
 
› Sending SMS With PHP

› MySQL Join Tutorial

› Make An RSS Feed Using PHP

› Intro To Object: Option Variables

› Design An Online Chat Room With PHP And MySQL

› Create Tell A Friend Script With HTML & PHP

› Benchmark And Optimize PHP Script Speed

› What Kind of DBA Are You?

› SQL Server Performance Counters

› SQL Server Performance Tips

more...
 
Random Articles
 
› Storing and Retrieving Variables From Application Object - Asp

› Date Manipulation In ASP

› Working with DataSet Objects and XML

› Displaying Data using ASP.NET 2.0 GridView

› Cascading Stylesheets Advantages: 5 Reasons To Use CSS

› Read and display a text file in Asp.net

› Search Engine Friendly Web Design - 3 Ways To Use CSS

› How to modify expire date of a cookie using Asp

› Benchmark And Optimize PHP Script Speed

› .NET Data Access Performance Comparison

more...
 
Home Mission About us Contact us Feedback Terms Conditions
2008 © Copyright TipsStation. All rights reserved.