Avoid unnecessary execution operations
Page_load
with
ISPostBack
Void Page_Load (Object Sender, Eventargs E) {
// ... set up a connection and command here ...
IF (! page.ispostback) {
String query = "select * from authors where firstname Like '% Justin%'"
MyCommand.Fill (DS, "Authors");
MyDataGrid.databind ();
}
}
Void Button_Click (Object Sender, Eventargs E) {
String query = "select * from authors where firstname Like '% BRAD%'";
MyCommand.Fill (DS, "Authors");
MyDataGrid.databind ();
}
Close unnecessary
Session
status
<% @ Page EnableSessionState = "false"%>
Pay attention
Server Control
You can not use it if you don't need it.
Server Control
You can close if you don't have need
ViewState
EnableViewState = "false" runat = "server" /> <% @ Page EnableViewState = "false"%> Do not use it EXCEPTION Control program process Try { Result = 100 / NUM; } Catch (Exception E) { Result = 0; } IF (Num! = 0) Result = 100 / NUM; Else Result = 0; Disable VB with JScript Dynamic data type <% @ Page language = "vb" strake = "true"%> Access using stored procedure data Read-only data access is not used Dataset use SqlDataReader instead Dataset SqlDataReader Yes Read-Only, Forward-Only shut down ASP.NET of Debug mode use ASP.NET OUTPUT CACHE Buffer data Page buffer <% @ OutputCache%> Duration VarybyParam Snipper VarybyControl Data buffer Expiration 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));