The performance optimization of ASP.NET

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

ASP.NET performance optimization recommendations

1,Database performance optimization

A,To minimize the database connection, and make full use of every database connection: connection to create, open and close are overhead. You can use the connection pool

B,The rational use of the stored procedure: stored procedures are stored in a set of pre compiled server SQL. The use of stored procedures can to avoid the numerous SQL compiler, subsequent queries can reuse the previous execution plan. In addition a stored procedure can reduce the cost of network transmission SQL statement

C,Optimization of SQL statement: This is too much, such as the rational use of the index, view, avoid the complex query


2,Optimization of operating performance of string

A,The use of a value type ToString () method

For different types of   +  connection, will happen packing operation into a reference type to add to the string. Packing will allocate a new object on the managed heap, the original value is copied into the new object, a very high price. Use the ToString () method can avoid packing, thereby improving performance

B,Use the StringBuilder class


3,Disable debug mode


4,As long as appropriate, as far as possible and the page output cache data


5,Don't rely on the exception code in order to control the normal program flow

Anomaly can be costly. So with the exception.


6,Use Page.IsPostBack to avoid unnecessary treatment and process


void Page_Load(Object sender, EventArgs e)  // Set up a connection and command

{

if (!Page.IsPostBack)

// The first loading to fill the data

String query = "select * from Authors where FirstName like '%JUSTIN%'"; 

myCommand.Fill(ds, "Authors"); 

myDataGrid.DataBind(); 

}



7,If you do not use the session state, can disable it or setting is read-only

A,If you want to disable page session state, please   @  Page  instruction in the   property is set to false; EnableSessionState . For example:

<%@ Page EnableSessionState="false" %>B,Note that if the page needs to access the session variable, but does not intend to create or modify them, then the   @  Page  instruction in the   EnableSessionState  property is set to ReadOnly.


8,Performance testing using the mature tools


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Olina at November 13, 2013 - 2:16 AM