Enable asp.net polling, DOT NET Programming

How to Enable ASP.NET polling?

All our database side is configured in order to get the SQL Cache working in the ASP.NET side we require to do some configuration in the web.config file.

The 2 attributes are require to set in the "web.config" file:-

  • Set the "Enabled" attribute to true to set the caching on.
  • Set the poll time attribute to the number of milliseconds between every poll

2415_asp.net polling.png

Figure :- Web.config file modifications for SQL cache

At last use the Cache dependency object in your ASP.NET code.

After that comes the final step to use our cache dependency with programmatic data caching,output caching  and data source control, .

For the programmatic data caching, we have to create a new SqlCacheDependency &  supply that to the Cache.Insert() process .  In the SqlCacheDependency constructor, you supply 2 strings. The first is the name of the database you defined in the element in the part of the web.config file e.g: Northwind. The second is the name of the linked table example: Products.

private static void CacheProductsList(List products) {SqlCacheDependency sqlDependency = new SqlCacheDependency("Northwind", "Products");

HttpContext.Current.Cache.Insert("ProductsList", products, sqlDependency, DateTime.Now.AddDays(1), Cache.NoSlidingExpiration);}

private static List GetCachedProductList()

{return HttpContext.Current.Cache["ProductsList"] as List;}

ClsProductItem is business class, and here we are trying to cache a list of ClsProductItem instead of DataSet or DataTable.

The following method is used by an ObjectDataSource Control to retrieve List of Products

 public static List GetProductsList(int catId, string sortBy)


//Try to Get Products List from the Cache

List products = GetCachedProductList();

if (products == null)


//Products List not in the cache, so query the Database layer

ClsProductsDB db = new ClsProductsDB(_connectionString);

DbDataReader reader = null;

products = new List(80);

if (catId > 0)


//Return Product List from the Data Layer

reader = db.GetProductsList(catId);


else {

//Return Product List from the Data Layer

reader = db.GetProductsList();


//Create List of Products -List if ClsProductItem-products = BuildProductsList(reader);


//Add entry to products list in the Cache CacheProductsList(products); }

products.Sort(new ClsProductItemComparer(sortBy));

if (sortBy.Contains("DESC")) products.Reverse();

return products; }

To perform the same trick with output caching, you simply need to set the SqlDependency property with the database dependency name and the table name, separated by a colon:

<%@ OutputCache Duration="600" SqlDependency="Northwind:Products" VaryByParam="none" %>

The same technique works with the SqlDataSource and ObjectDataSource controls:


Posted Date: 9/21/2012 9:12:26 AM | Location : United States

Related Discussions:- Enable asp.net polling, Assignment Help, Ask Question on Enable asp.net polling, Get Answer, Expert's Help, Enable asp.net polling Discussions

Write discussion on Enable asp.net polling
Your posts are moderated
Related Questions
Explain Custom Activities. In addition to the standard activities available within the base activity library, you can make new activities to meet exact business needs. Creating

Project Description: Program or Fan Page Poster for facebook fan pages. Major task of this program would be posting pictures on your facebook fan page from other users fan pa

Problem: (a) Define the term ViewState as used in the ASP.NET framework. (b) What is a StateBag class? Give a simple example to support your answer. (c) (i) Distingui

Problem: (a) Explain the difference between these two lines of ASP codes: (b) The VBScript language includes some built-in functions which are often used in ASP co

Hello, I want to develop one crystal report. I have one database which has 5 field.One is string and others are Boolean. String field name is State and Four remaining fields are Th

What's difference between "Optimistic" and "Pessimistic" locking? In the pessimistic locking when user wants to update a data it locks the record and till then no one can updat

Need Experienced dot Net and PHP Programmers Project Description: Need Experienced dot Net., JSP, PHP, Java Programmers Skilled professional and command in Programming eit

What is the difference between "DataSet" and "DataReader"? The major differences between "DataSet" and "DataReader" are as follows:- 1)The "DataSet" is a disconnected archit

Web application and XML data storage One person should create a library (Java package of classes) for managing the list of bibliography entries, and for saving and loading th

What is event bubbling? The Server controls such as  DataList, Datagrid,  Repeater can have another child controls inside them. For example the DataGrid can have combo box ins