To improve performance of ASP.Net Web Applications, first of all we need to understand the places where performance bottlenecks typically occurs, the cause of these performance bottlenecks, and what steps need to be followed to prevent these performance bottlenecks.

Here I am going to list some of the best practices as per my experience and which I have used in my couple of ASP.Net projects to improve the performance of asp.net web applications:

1. Reduce Web Page Size:
Reduce the size of ASP.Net web pages. Processing large pages increases the load on the web server and increases the consumption of network bandwidth which will significantly increases the response time for clients. We can reduce the size of ASP.Net web pages by using following steps:

  • Break a large web page into multiple web pages
  • Rather that writing JavaScript code within the ASP.Net web page, write it in a .JS file and attach this file to ASP.Net web page using script includes.
  • Remove the white spaces (tabs and spaces) from HTML and ASP.Net code of the web pages

2. Use Page.IsPostBack Property:
Use Page.IsPostBack property to ensure that the page initialization logic executes only once when the page loads first time and not in the response to the client postbacks.

3. Set debug attribute to false:
Before deploying the ASP.Net web application or starting performance testing, make sure that the debug attribute is set to false in the web.config file and also in the web pages. If debug is set to true, it generates some additional files in the Temporary ASP.Net Files folder and also the System.Diagnostics.DebuggableAttribute attribute is added to the generated code, which significantly reduces the processing of web pages.

4. Use Caching:
Make use of ASP.Net caching wherever applicable to avoid unnecessary database lookups and other expensive data retrieval operations.

5. Disable ViewState:
Disable ViewState if there is no need of it. ViewState can be disabled for a particular control or at page level. Some of the examples where ViewState is not required: if web page is output only, if the page data is reloaded on each postback, if server control events are not handled, etc. 

6. Use Connection Pooling:
For Database driven web applications, enable connection pooling which allows to reuse to the open database connections.

7. Use DataReader:
Use DataReader instead of DataSet wherever applicable. DataReader allows fast and efficient data binding.

8. Use Session State Efficiently:
If Session State is not used in your application, then you should disable Session State in your web application to eliminate redundant session processing performed by ASP.Net. Session State can be disabled by using following settings:

  • To disable Session State for all the ASP.Net web applications in a web server, apply following setting in the Machine.config file:   <sessionState mode="Off" />
  • To disable Session State for a specific ASP.Net web application, apply following setting in the Web.config file of that web application:   <sessionState mode="Off" />
  • To disable Session State for a specific web page, apply following setting in the Page directive of that web page:   <@ Page EnableSessionState="false" .... />

9. Close or Dispose Resources Explicitly:
Once an object is no longer required for further processing, just call Dispose or Close method if one is provided to claim the memory and other resources used by this object. In general all the classes that implements IDisposable interface provides Close or Dispose methods.

10. Use Client-side Data Validation:
Use client-side data validations to reduce the round trips to the server. Client-side validations are already available out-of-the-box in all the ASP.Net data validation controls.

11. Use Server.Transfer instead of Response.Redirect:
Response.Redirect forces the client browser to send a new request to the server by using the specified URL while Server.Transfer avoids this and makes a server-side call directly. So its better to use Server.Transfer instead of Response.Redirect wherever applicable.