Enable asp.net polling, DOT NET Programming

Assignment Help:

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);

reader.Close();

//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:

 


Related Discussions:- Enable asp.net polling

How many types of generations are there, How many types of generations are ...

How many types of generations are there in a garbage collector? Memory management in the CLR is separated into three generations that are building up by grouping memory segment

Application that tracks production costuming, The costumer is an applicatio...

The costumer is an application that tracks production costuming, structure and other related pieces. We discussed this in detail and you have commentary and video to define the pro

Asp.net 2.0 application port to asp.net mvc, ASP.NET 2.0 application port t...

ASP.NET 2.0 application port to ASP.NET MVC Project Description: Legacy ASP.NET application for managing tasks for a private client needs a complete re-write. The applicat

Difference between asp and asp.net, The ASP.NET new feature supports are sh...

The ASP.NET new feature supports are shown below :- Better Language Support 1) The New ADO.NET Concepts have been implemented. 2) The ASP.NET supports complete  language

I want a panel for youtube views and facbook, I want a Panel for youtube vi...

I want a Panel for youtube views and facbook likes. I need a panel made that can increase facebook fanpage likes, and that will increase youtube video views. Youtube views an

Class in dot net, What is a Class in dot Net? The class describes all t...

What is a Class in dot Net? The class describes all the attributes of objects, as well as the methods which implement the behavior of member objects. It is a comprehensive data

Regular it support work, Regular IT Support Work Project Description: ...

Regular IT Support Work Project Description: I have a number of clients in the UK that I give you IT support for on their Windows desktops and servers and linked peripherals

Can event''s have access modifiers?, The Events are always public as they a...

The Events are always public as they are meant to serve each one registering to it. But you can access modifiers in the events.You may have events with protected keyword which will

What are the benefits of using of ado.net in .net 4.0, What are the benefit...

What are the benefits of using of ADO.NET in .NET 4.0. The following are the benefits of using ADO.NET in .NET 4.0 are as follows: Language-Integrated Query (LINQ) - Adds

Gantt & pert charts.., help me to prepare the above charts for my online v...

help me to prepare the above charts for my online vegetable selling project

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd