Blog

Internet Marketing Company

Ashish Mishra

Optimizeing Your Asp.net Pages for Better Performance!!!


If you know the internet and all of the website development to Asp.Net you will unavoidably know about the wonders of the DataGridDataList, and Repeater controls in Asp.net. While each of these has its place, if you are only displaying data there is a much faster and more effective means to do so.

Let’s say you have a articles page that displays articles based on a query string. Each article is stored in a database and displayed on the page based on the unique id of the article as stored in the database.

A typical asp page execution process goes something like this. The code queries the database based on the Article id and then brings back that information to the page where you display it in the style that you would like. This is a adequately straight forward approach with asp and is done all the time.

So how do we speed up our asp.net pages?

There are some tips that performs that task..

1# Use Caching!

Basically on the place of querying the database each time the page is loaded you only query the database once and load that result into the system cache. Consecutively calls to load the page retrieve the data from the cache as obstructed to the database which gives you an very fast and considerable performance boost. You can then set the cache for how long the cache should store your information as well as many other features. If you are not using the cache, you should be whenever possible.

2# If possible, do NOT use the standard Asp.Net controls.

The standard asp.net controls are designed for rapid development and not for page performance. They allow you to design pages that capture and display data very quickly but their actual performance suffers because of the extra overhead which is there for ease and speed of development time and not page execution speed.

Use either a User Control or even better yet a Web Custom Control which is by far the fastest performance wise and really quite easy to create and use.

3# Use an SqlDataReader or even better yet use a set based command for Sql Server data retrieval and simply execute that one command against the database.

An asp.net SqlDataReader is a fast forward only datareader that closes the connection after it reads the last set of results.

If you had more than 1 result returned, in your table of contents for instance, you would use the SqlDataReader because you are returning different sets of results.

Set based commands are stored procedures that take back data through parameters as opposed to a result set which then in turn needs to be looped through to get your data. So instead of writing your stored procedure like the following which brings back 1 result set.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Blogosphere News
  • LinkedIn
  • Live
  • MySpace
  • Technorati
  • TwitThis
  • YahooMyWeb

Tags:

Leave a Reply