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

What are the differences between asp and asp .net, What are the differences...

What are the differences between ASP and ASP .Net ?  ASP: Code is Interpreted ASP.NET: Code is Compiled   ASP: Business Logic and Presentation Logic are in a one

Samba pos development customisation english version, Project Description: ...

Project Description: customise samba pos. Just remove samba pos logo and rebrand it. The title in the frame needs to be changed as well as the splash screen at the beginning.

Abstract classes, What are abstract classes? The features of the abstra...

What are abstract classes? The features of the abstract class are as follows:- 1.     You can not create an object of the abstract class. 2.     The Abstract class is des

I need unity 3d texture painting plug-in, Project Description: I require...

Project Description: I require a custom texture painting plug-in for the latest version of Unity 3D. The project can have features that are common in Photoshop and Mari for pain

Is it good to distribute implementation to remoting client?, It's never tol...

It's never told  to distribute complete implementation at client, due to following shown  reasons:- 1) Anyone can use ILDASM and decrypt your logic. 2) It is a bad architectu

What is the difference between int and int32, What is the difference betwee...

What is the difference between int and int32. There is no difference among int and int32. System.Int32 is a .NET Class and int is an alias name for System.Int32.

Jquery and mvc 4.5 training session, Jquery and MVC 4.5 Training Session ...

Jquery and MVC 4.5 Training Session I am looking who have industry experience working on Microsoft Technology ( MVC 4.5 ) and Jquery, who will take live online session and provi

Unhandled exception occurred during the execution, Project Description: ...

Project Description: I have a site that's previously fully developed, and need to fix some small problems (Text editor posting error, and a Server error caused by some Nhibernat

Array list, What is Array List? An Array is whose size can increase or ...

What is Array List? An Array is whose size can increase or decrease dynamically. The Array list can hold item of various types. As Array list can increase and decrease his size

Design algorithm - refactoring, TASK - DESIGN ALGORITHM You are required...

TASK - DESIGN ALGORITHM You are required to design a suitable solution algorithm by using either structured chart, pseudocode or flowchart. This diagram should clarify the proce

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