Performance

Performance is often a vitally important issue in computer applications, especially in web applications receiving a large number of requests. One obvious way to improve performance is to buy faster hardware with more memory. But you can also tune your code to enhance performance in many ways, some of them significant. We’ll begin by examining some of the areas specific to ASP.NET which offer the greatest performance improvements and then examine some of the general .NET topics related to improving performance.

Tip

Several Microsofties involved with actually writing the .NET Framework used the word performant to mean that something is delivering higher performance. We can’t find the word in our dictionary, but it seems like a good word.

ASP.NET-Specific Issues

Correctly using the following features of ASP.NET offers the greatest performance improvements when an ASP.NET application is running.

Session state

Session state is a wonderful thing, but not all applications or pages require it. For any that do not, disable it.

Session state can be disabled for an entire application by setting the EnableSessionState attribute in the Page directive to false, as in:

<%@ Page Language="VB" EnableSessionState="false"%>

If a page will not be creating or modifying session variables but still needs to access them, set the session state to read-only:

<%@ Page Language="VB" EnableSessionState="ReadOnly"%>

By default, web services do not have session state enabled. They only have access to session ...

Get Programming ASP.NET, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.