Search Web

Monday, October 14, 2013

Tips to Improve ASP dotnet Application Performance


There are certain things you should take into account when you are developing your applications.

I have learned to avoid and do certain things that increase your application performance by a massive amount!

1)Avoid Server-Side Validation

Try to avoid server-side validation, use client-side instead. Server-Side will just consume valuable resources on your servers, and cause more chat back and forth.

2)Repeater Control Good as Compare to  DataList, DataGrid, and DataView controls.

Asp.net is a great platform, unfortunately a lot of the controls that were developed are heavy in html, and create not the greatest scaleable html from a performance standpoint. ASP.net  repeater control is awesome!  Use it!  You might write  more code, but you will thank me in the long run!

3)Always check Page.IsValid when using Validator Controls

So you’ve dropped on some validator controls, and you think your good to go because ASP.net does everything for you!  Right?  Wrong!  All that happens if bad data is received is the IsValid flag is set to false. So make sure you check Page.IsValid before processing your forms!

4)Page.IsPostBack

Make sure you don’t execute code needlessly. I don’t know how many web developers forget about checking IsPostBack!  It seems like such a basic thing to me!  Needless processing!

5)Avoid Exceptions

Avoid throwing exceptions, and handling useless exceptions. Exceptions are probably one of the heaviest resource hogs and causes of slowdowns you will ever see in web applications, as well as windows applications.  Write your code so they don’t happen!  Don’t code by exception!

6)Turn Off ViewState

If you are not using form postback, turn off viewsate, by default, controls will turn on viewsate and slow your site.Example :-if You Have Used Lable to display name static.

 
 ForeColor="Red" EnableViewState="false">


7)Use the Finally Method

If you have opened any connections to the database, or files, etc, make sure that you close them at the end!  The Finally block is really the best place to do so, as it is the only block of code that will surely execute.