Welcome to make progress together !!!
1. In compilation, set debug to false as follows:
Default language = "C #" DEBUG = "false">
2. Use server. Transfer instead of response. Redirect.
3. Check page. isvalid frequently when using the validator control.
4. Use a foreach loop instead of a string iteration loop.
5. Use the client authentication method (do not verify on the server every time ).
6. To avoid duplicationCodeRun the command. Check "Page. ispostback ".
7. gif is similar to PNG, but PNG usually produces a small file. (Of course, Some browsers do not support PNG format)
Use appoffline.htm to update the binary file.
9. Disable tracking unless necessary.
< Trace Enabled = "False" Requestlimit = "10" Pageoutput = "False" Tracemode = "Sortbytime" Localonly = "True" />
10. Disable autoeventwireup on the Compilation page. Set autoeventwireup to false in the machine. config file.
11. If not, close the session.
< Sessionstate Timeout = "20" Cookieless = "False" Mode = "Off" Stateconnectionstring = "TCPIP = FIG: 42424" Sqlconnectionstring = "Data Source = 127.0.0.1; trusted_connection = No" >
12. In the application where you generate the final versionProgramSelect the release mode. The default value is debug.
13. Disable viewstate if you do not need it.
Enableviewstate = "false"
14. Avoid frequent database access.
15. Use cache to improve the performance of your application.
16. Verify all user input.
17. Release all resources.
18. String and stringbuilder.
When modifying a string, use stringbuilder instead of string. During each string modification, string occupies different memory spaces, while stringbuilder only uses the same memory space.
19. Do not directly use the object value. Obtain the object value from the local variable before using it. Because it takes more time to directly read the object value than to read the variable.
20. Avoid exceptions: use if.
21. code optimization: Avoid using X = x + 1, but use X + = 1.
22. Data Access Technology: datareaders provides fast and effective data retrieval methods. In terms of performance, datareader is much faster than datasets.
23. Check to ensure response. isclientconnected before processing a bulky ASP code.
24. Avoid session variables because each ASP page runs in different threads and Session calls will be serialized one by one. This will reduce the application. You can use the querystring set or the Hidden variable on the form to save the value.
25. Make the buffer effective and improve the performance, such: <% Response. Buffer = True %>
Use:
<% Response. Flush = True %>
26. Use the Repeater control instead of the DataGrid and datalist, because it is efficient, customizable, and programmable.
27. retrieving a large amount of data in the database consumes more time in the data list.
The page displays specific data, but all data loads must be considered. Only the data required for the current page is retrieved.
28. Avoid embedding JavaScript and CSS.
29. Use a single CSS file instead of multiple CSS files.
Please merge all your CSSS into a CSS class file as much as possible. Large files and large. CSS files will cause a large number of requests .. CSS files are usually stored by the browser. Such a single. CSS file does not cause a long wait for each page request. Embedded. CSS class leads to heavy HTML, So I think: the first line is to upload a single.css file.
30. Reduce the cookie size.
31. Compress CSS, JavaScript, and images.
You can use online compression and File compression to replace the following webpage and optimized code with your file content.
Http://iceyboard.no-ip.org/projects/css_compressor[^] CSS Compression
Www.xtreeme.com/javascript-optimizer/##]. js Compression
32. Use the cache as appropriate.
I. Page output cache:
<% @ Outputcache duration = " 3600 " Varybyparam = " None " %>
Ii. Page segment cache:
Write the page output cache in each user control
Iii. Data Cache:
Code
< Script Language = "C #" Runat = "Server" >
Protected Void Page_load (Object SRC, eventargs E)
{
Dataview dv = (Dataview) cache. Get ( " Employeesdataview " );
If (dv = Null )
{ // Wasn' t there
Sqlconnection Conn = New Sqlconnection ( " Server = localhost; uid = sa; Pwd =; database = test " );
Sqldataadapter da = New Sqldataadapter ( " Select * from employees " , Conn );
Dataset DS = New Dataset ();
Da. Fill (DS, " Employees " );
DV = DS. Tables [ " Employees " ]. Defaultview;
Cache. insert ( " Employeesdataview " , DV );
Conn. Close ();
}
Else
Response. Write ( " <H2> loaded employees from data cache! </H2> " );
Lb1.datasource = DV;
Lb1.datatextfield = " Name " ;
Lb1.datavaluefield = " Age " ;
Databind ();
}
</ Script >
33. The server uses the port80s compression software http://www.port80software.com/products/httpzip/?###.
34. "using" is used ".
35. Do not declare the member variables as public or proteted. Try to use the private member variables and public/protected attributes.
36. Use strstring = string. Empty instead of strstring = "".
37. Please try to reduce your page files as much as possible and avoid unnecessary labels. For example, use Div instead of table.
38. Write static messages in the DIV and display them only when necessary. This is faster than setting the text attribute of the label and Div on the server.
39. If possible, retrieve the data in the database at one time. Try not to add database access. Therefore, integrate and select datafields from different tables.
40. Give webcontrol a brief name.