13 October 2010

Optimizing asp.net applications

   Performance tuning is an extremely important issue to both the developer writing code and the system administrator maintaining the application.
    The following guidelines list specific techniques that you can use to avoid performance bottlenecks.


1.State Management
    Disable session state when you are not using it. Not all web application require a session state for each user.
To disable session state for a complete page in your application, use the following code.        

                     <%@ page EnableSessionState="false" %>
To disable  session state for the entire application, open the 'web.config' file, and set the mode attribute to off under the session state section as in the following code:
                    <SessionState mode="off" />


2.Data Access1.Use SQL Data Reader instead of datatabe and dataset whenver it is possible
2.Use compiled stored procedure instead of SQL plain text commands, this gives your application an extra speed performance. SQL server builds and stores execution plans for previously stored procedures.
3.use of Paging  in data Controls like gridview and listview
4.Avoid Multiple trips to Database


3.Use HTML controls whenever possible.

4.Avoid round trips to server whenever possible.
For example, validating user inputs can always (or at least in most cases) take place in the client side. There is no need to send these inputs to the server to check their validity

5.Use Page.IsPostBack to avoid performing unnecessary processing on a round trip.

6.Server Controls View State
Server control by default saves all the values of its properties between round trips, and this increases both page size and processing time which is of course an undesired behavior. Disable the server control view state whenever possible.

7.Before deploying your web application  disable the debug and trace mode.

8.Exception handling
Avoid common exceptions like null reference, dividing by zero , and so on by checking them manually in your code. Dont always rely on TRY CATCH.

9.Use of StringBuilder Class when there string is modified more than 2 times.

10.Use the Server.Transfer method to redirect between pages in the same application.
Using this method in a page, with Server.Transfer syntax, avoids unnecessary client-side redirection.

No comments:

Post a Comment

Your comments, Feedbacks and Suggestions are very much valuable to me :)

Things are upgraded

My Dear readers, I am really thankful for being supportive all these years. This site was the first blog site I ever created in my life...