a blog for those who code

Friday, 25 July 2014

How to improve Asp.Net Application Performance - Part 1

In this post we will show you how using simple tips you can improve the performance of your Asp.Net application.

1. Use of Finally Method

Yeah its very important to use Finally Method as Finally block is the best place to close all your connection if any exception occurs.If in your application you have opened any connections to the database, or files its always recommended to close all of them at the end. The code inside a finally block will get executed regardless of whether or not there is an exception.

try {

catch {

finally {
// executes regardless whether or not there ia an exception

2. Check IsClientConnected

You should check HttpResponse.IsClientConnected property to verify that the client is still connected before doing any operation, as sometimes its reduces the time of round trips.

//Do Heavy operation

3. Use Page.IsPostBack

You should use Page.IsPostBack property to reduce redundant processing and avoid unnecessary initialization costs. Sometimes you need to do some stuff only for the first time when the page is loaded so, those stuff can be written inside the below if statement.

if(!Page.IsPostBack) {
 // Code to execute for the first time when the page loads

4. Use Server.Transfer instead of Response.Redirect

Why use Server.Transfer instead of Response.Redirect because it will save some time by avoiding client-side redirection.

But you can only use Server.Transfer if you want to change the focus of the page in the same application. Now suppose if from your application you want to call "www.google.com", then you cannot use Server.Transfer instead you have to use Response.Redirect. Also if you need authentication and authorization checks during your transfer of pages, you have to use Response.Redirect.

5. Use Caching and Output Buffering

Try to use Caching if your application have static data or nearly static data (infrequently updated). If the whole page cannot be cached try to cache a portion of the page. Using output caching to cache the entire page or portions of the page can significantly improve performance.

You can even reduce the round trips whenever possible if you can buffer your output. Buffering causes the server to buffer the output and send it only after it has finished processing the page. So let me tell you what happens when buffering is disabled, the process needs to continuously stream responses from all concurrent requests thus making it very heavy operation.

These are simple steps which you can follow to improve the performance of your dot net applications. Soon I will show you some more steps which helps you to improve the performance of your dot net applications.

Please Like and Share the Blog, if you find it interesting and helpful.

No comments:

Post a Comment

Contact Us


Email *

Message *


Best Hosting Plans

CC License