Optimization Tips For ASP.NET Applications
Although the ASP.NET model has been revised and many new features have been
added to enhance the web application development and execution, still there
exists the need for optimizing your application performance by keeping the
resource utilization to the minimum. Here are some tips for optimization.
-
Disable the session state when it is not required. By default the
session state variables are set to true. If not required or being used in your
applications, these should be set to false, because maintaining session state
consumes memory and processing time.
-
Avoid excessive round trips. The controls provided with ASP.NET
enable roundtrips to the server, that increases processing load on the server.
This should be avoided and the controls should be programmed to generate
client-side script where possible.
-
Use server controls with care. Although they are rich in
functionality, but their rich functionality is due to their execution on the
server end. Server controls should be used wisely as they also consume server
resources for their event based functionality.
-
Use Page.IsPostback. The Page.IsPostback method avoids extra
roundtrips on the server-side. It also helps in determining if regeneration of
data is required or not.
-
Avoid control view state where possible. Like the session state
property this property is also set to true by default. This property should be
disabled when not required. The property helps the server controls remember
their state and values, thus making use of the server resources.
-
Use <%@ Page Language="VB" Strict="true"%> for early binding. Early
binding helps makes code more efficient and the Strict option bounds you to
declare your variables before using them.
-
Stored Procedures. Stored procedures are also a mean of faster
execution because they are kept in a pre-compiled form. With the provision of
Managed Drivers for SQL Server in the .NET framework the estimated performance
gains with using stored procedures are 200-300% over Oledb or ODBC
connections.
-
User Data Reader where possible. Like generation of data requires a
lot of resources, similarly creation of the datasets also requires a lot of
resources, the data reader acts like the firehose cursor, and
utilizes less resources. The datasets should not be used in situations where
not heavy amounts of data are to be worked upon.
-
Caching. Use caching where possible, it helps in less consumption
of resources and rapid providence of material to the visitor.
-
Disable Debug mode. The debug mode when set to true, forces
the compiler to look for errors and is most expensive in terms of processing.
A more comprehensive list for optimization tips is also
available on MSDN. Please refer to the following link for viewing that list.
Optimization Tips on MSDN
|