1. Use the IsPostBack attribute to avoid unnecessary operations.
Code
// This event will be executed as long as the interaction is useful.
Void Page_Load (Object sender, EventArgs e ){
If (! Page. IsPostBack ){
String query = "select * from Authors where FirstName like '% JUSTIN % '";
MyCommand. Fill (ds, "Authors ");
MyDataGrid. DataBind ();
}
}
2. disable unnecessary Session states (when a user redirects between Web pages of an applicationSessionThe variables in the object will not be lost)
<%@ Page EnableSessionState="false" %>
3. Use Server Control
You can disable ViewState (the life cycle is only the current page) when you do not need to use Server Control)
EnableViewState is set to false. When sending back, the status of the controller is restored to the initial setting on the aspx page.
<Asp: datagrid EnableViewState = "false" runat = "server"/>
// Close the ViewState of the entire page
<% @ Page EnableViewState = "false" %>
4. Do not use Exception to control program processes
5. Disable VB and JScript Dynamic Data Types
<%@ Page Language="VB" Strict="true" %>
6. Try to use stored procedure data for access
7. Do not use DataSet for read-only data access
Use SqlDataReader to replace DataSetSqlDataReader with read-only, forward-only
8. Disable ASP. NET Debug mode
9. use ASP. NET Output Cache to buffer data
<%@ OutputCache Duration ="120" VaryByParam ="TextBox1;TextBox2" %>
Duration: buffer time VaryByParam: When the combination of TextBox1 and TextBook2 is changed, the Cache will be added. If it is set to None, the Cache value will be used regardless of whether the TextBox1 and TextBox2 values change.
VaryByControl: You can apply the <% @ OutputCache %> command to the user control. For more information, see OutputCache.
10. data buffer Cache
Code
Cache.Insert("MyData", Source, new CacheDependency(Server.MapPath("authors.xml")));
Cache.Insert("MyData", Source, null,
DateTime.Now.AddHours(1), TimeSpan.Zero);
Cache.Insert("MyData", Source, null, DateTime.MaxValue,
TimeSpan.FromMinutes(20));