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

Anomalous Debugging Behaviour in Visual Studio 2013

I encountered a strange issue while I was debugging a C# project using Visual Studio 2013. Whenever I hit any breakpoints during debugging, I could not check the “watch” values of any variables or expressions. I could not check those values through “Immediate Window” too. I kept getting “Could not evaluate expression” error as shown below.


Continue reading

Web Performance and Load Testing

I am writing this particular post just to mention “Web Performance Test Recorder” in my blog. This is a very useful tool that can be used for load testing the web applications. Though it is available in only the Ultimate flavor of the Visual Studio 2010, Microsoft has made it available to all the flavors of VS for the higher versions.

The reason I have focusing on this tool is that this tool has helped my team fix a weird issue recently. Of course, we, as a developer, find every other issue to be weird. 🙂 We had a new release pushed into the production. And out of the blue, we are getting GeneralADOException exceptions related to failed inserts, updates to our Oracle backend. Everything was working just fine. Our local development environment worked like a charm, as usual. :p The damned production and UAT sites were logging these numerous errors. After brainstorming for a couple of days, one of the geeks from our team decided to load test the web, using this tool and Voila! the source of issue was found. Phew!!!

Since then, I have become a huge fan of this tool. MSDN has provided a very detailed documentation for getting started with Web Performance and Load Testing here.

I hope you can benefit from this, as I and my team did. 🙂

Happy Coding!!! 🙂