Click here to Skip to main content
15,867,594 members
Articles / Web Development / ASP.NET
Tip/Trick

Improve ASP.NET Web Application Performance

Rate me:
Please Sign up or sign in to vote.
4.43/5 (7 votes)
2 Jul 2010CPOL3 min read 26.7K   10   9
Tips on how to improve ASP.NET web application performance
1) Turn off Tracing unless until required

2) Turn off Session State, if not required
3) Disable View State of a Page if possible

4) Set debug=false in web.config

5) Avoid Response.Redirect

6) Unnecessary round trips
7) Avoid throwing exceptions

8) Use Finally method to kill resources

9) Use Client Side Scripts for validations

10) Avoid unnecessary round trips to the server

11) Use Page.ISPostBack

12) Include Return statements with in the function/method

13) Use Foreach loop instead of For loop for String Iteration

14) Avoid unnecessary indirection

15) Use "ArrayLists" in place of arrays
16) Always check Page.IsValid when using Validator Controls

17) Use Paging

18) Store your content by using caching
19) Use low cost authentication

20) Minimize the number of web server controls

21) Avoid using unmanaged code

22) Avoid making frequent calls across processes

23) Cleaning Up Style Sheets and Script Files
24) Design with ValueTypes

25) Minimize assemblies

26) Encode using ASCII when you don't need UTF

27) Avoid Recursive Functions / Nested Loops

28) Minimize the Use of Format ()

29) Place StyleSheets into the Header

30) Put Scripts to the end of Document
31) Make JavaScript and CSS External
32) Use StringBuilder when alter a string.In C# a string is immutable and cannot be altered, its actually creating a new string, which in turn uses more memory than necessary, creates more work for the garbage collector and makes the code execution run slower.
33) For casting an object to another object, use as operator

34) Choose readonly over const. Becuase const evaluated at compile-time which means if it's changed at a later date, you have to not only recompile that application, but all applications that reference that application. In constrast, readonly is evaluated at run-time providing you a lot more flexibility.

For Database Operations

1) Return Multiple Resultsets

2) Connection Pooling and Object Pooling
3) Use SqlDataReader Instead of Dataset wherever it is possible
4) Keep Your Datasets Lean
5) Avoid Inefficient queries
6) Avoid joining as much as possible
7) Unnecessary round trips
8) Too many open connections
9) Avoid Transaction misuse
10) Avoid Normalized tables
11) Reduce Serialization
12) Do Not Use CommandBuilder at Run Time
13) Use Stored Procedures whenever possible
14) Avoid Auto-Generated commands
15) Use Sequential Access as often as possible
16) Use commandParameter for passing parameter in stored procedure/query
17) In case of passing commandParameter specify datatype length if possible
18) Implement paging at stored procedure level, retrieve only chunk of data that you need to display after paging.

ASP.NET applications developed using VB:

1) Enable Option Strict and Option Explicit for your pages
2) Use early binding in Visual Basic or JScript code
3) Put Concatenations in One Expression
4) Avoiding Use of Class Destructors. Class destructors (implemented as the Finalize() method in VB.NET) cause extra overhead for the garbage collector, because it must track which objects have been finalized before their memory can be reclaimed

Some other points to remember

1) Do not overload you App_Code folder with DAL/BLL codes.Use separate layer for them
2)Minimizing Method Calls by investigating common functions
3) Avoid over use of collection
4)The .NET garbage collection scheme can intentionally delay reclamation of objects until memory is available, so keep in mind how you are playing with objects

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Wipro
India India
Asp.net,Ajax,Webparts,Web service,Window application,Window service,Sql Server

Comments and Discussions

 
GeneralNice Pin
Aasif Inamdar1-Feb-12 21:47
Aasif Inamdar1-Feb-12 21:47 
Generalxcvcxv Pin
Aasif Inamdar1-Feb-12 21:47
Aasif Inamdar1-Feb-12 21:47 
GeneralReason for my vote of 5 Good tips Pin
Shahriar Iqbal Chowdhury/Galib4-Jul-10 8:09
professionalShahriar Iqbal Chowdhury/Galib4-Jul-10 8:09 
GeneralReason for my vote of 5 Excellent Pin
Shahriar Iqbal Chowdhury/Galib2-Jul-10 9:08
professionalShahriar Iqbal Chowdhury/Galib2-Jul-10 9:08 
GeneralGood points but.... Pin
Hemant__Sharma28-Apr-10 21:17
Hemant__Sharma28-Apr-10 21:17 
GeneralRe: Good points but.... Pin
Niklas L1-Jul-10 23:04
Niklas L1-Jul-10 23:04 
GeneralGood One to implement Pin
Chetan Patel13-Apr-10 8:25
Chetan Patel13-Apr-10 8:25 
GeneralRe: Good One to implement Pin
keyur soni14-Apr-10 2:21
keyur soni14-Apr-10 2:21 
GeneralGreat tip Pin
Gaurav Dudeja India8-Apr-10 20:23
Gaurav Dudeja India8-Apr-10 20:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.