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

› Simple ASP Image Resize Function

› Install AJAX On Machines Running Visual Studio 2005

› ASP.Net Interview Questions And Their Answers

› Creating Pretty Popups Using AJAX

› Encode Url using ASP

› SQL Server Performance Counters

› .NET Data Access Performance Comparison

› UpdatePanel control in Asp.net Ajax

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
 
› Ten Tips To Optimize Your Website

› Understanding DDL Triggers In SQL Server 2005

› What Kind of DBA Are You?

› Alternating Row Colors

› .NET Data Access Performance Comparison

› CSS Cursors - How To Use Them

› Clear all Cached objects in Asp.Net

› Encode Url using ASP

› Search Engine Optimization & Submission Strategies - A Beginners Guide

› How To Set Up A 301 Redirect On IIS

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