Optimization techniques for improving ASP.NET performance

It is a common scenario when a developer has to work on improving the performance of existing product built years ago by someone who has already left the company. In such cases, one may be in a dilemma on where to start looking for the performance bottlenecks. In this post, I am going to list out some of the areas worth focusing while trying to optimize existing code base in a .NET web application.

a. State Management

  • Store light-weight, user-specific state in the client side using query string, hidden variables and cookies.
  • Use static properties instead of the Application Object to store Application State because we can access a static variable faster than an item in the Application dictionary.
  • Disable Session State if you do not use it. This eliminates redundant session processing performed by ASP.NET.
  • Set the session state behaviour i.e. EnableSessionState to ReadOnly if the page does not need to update session variable values. This results in fewer database calls and improves performance.
  • Disable View State if your page does not post back and the server controls are repopulated with every page refresh. By default, view state is turned on by ASP.NET.

Continue reading