1. Disable session
Be sure to disable this if you are not using session-tracking. You can set the following in each asp.net page:
<%@ Page language= "C #" codebehind= "WebForm1.aspx.cs" autoeventwireup= "false" inherits= "Webapplication1.webform1"
Enablesessionstate= "false"%>
Of course you can design the <sessionstate>mode value off in the Web.config application configuration settings.
2. Output Buffer Settings
This method is very helpful to your application.
asp.net applications are basically generating data in bulk on the server side, you must set up Response.Flush emptying buffers. This will reduce the buffer pressure on the server side.
<%response.buffer=true%>
Replace into
<%response.flush=true%>
3. Avoid server-side validation.
Server-side validation is replaced with client-side validation. Server end data validation will consume your server heavily
And will come back with a lot of page data.
4. Use Repater controls as much as possible, rather than using DataList, DataGrid, and DataView controls
ASP.net is a very good platform, unfortunately, there are many controls that generate a lot of HTML code, which
The sample must cause a performance problem. asp.net repeater controls are easy to use. Use it you will be
Write some extra code, but in the future you'll find that the benefits of it are much more troublesome than writing code.
5. Please use httpresponse.isclientconnected when performing big action
if (response.isclientconnected)
{
If still connected, redirect
to another page.
Response.Redirect ("Page2cs.aspx", false);
}
Response.Redirect What's wrong, please continue the answer below
6. Use HttpServerUtility.Transfer to replace Response.Redirect.
Redirect (redirect) is very troublesome, it is only used to jump from the current physical server to other services
If only the page jumps in this server please use Transfer (forwarding), this will reduce a lot of no
There is a necessary client request.
7. When using server-side validation, be sure to use Page.IsValid to check whether the page can be validated
Because you are using a validation control, you might think that ASP.net will handle all of the following things, right?
Wrong! The Isvlid property is changed to Fasle when invalid data is uploaded to the server side. Check the Page.IsValid property before proceeding with your form
8. Deploy the application, use release version
When you deploy your application, make sure that your application should be release version instead of Debug. If you think it's irrelevant, you're wrong.
If you use the debug template, the request timeout is extremely easy to occur. Deploy the release version, and you'll see a great increase in speed.
9. Close tracing (tracking)
Tracing is very scary and you have not forgotten to close it. If it doesn't work, make sure to edit the web.config and close it. It will consume a lot of your program resources
<configuration>
<system.web>
<trace enabled= "false" pageoutput= "false"/>
<trace enabled= "false" requestlimit= "ten" pageoutput= "false" tracemode= "SortByTime" localonly= "true"/>
<compilation debug= "false"/>
</system.web>
</configuration>
10.page.ispostback to use it regularly.
Please make sure that you don't execute too many return codes, I can't remember how many developers forgot to use the Check IsPostBack property. I often use this property check in my normal development.
11. Avoid using exceptions
Avoid throwing exceptions and handling exceptions. Unless you use exception handling in case of last resort.
Exceptions are a considerable waste of server-side resources and can greatly reduce efficiency. Try not to use exception handling.
12. Set Cache (Caching)
Use the page to quickly set the page caching and use the asp.net buffer api!
There are a lot of things to learn, this is not as simple as you think. There are a lot of strategies to adopt. When do I use buffering? Do you use the cache?
13. Set each request cache
Use Httpcontect.items to add only one page to set up each request cache.
Use of the 14.StringBuilder class
The speed of stringbuilder.append is much faster than string + string.
If the string you are connecting to is not available, it is recommended that you use the Stringbuilder.append method when the number of connections is greater than 3 times, and of course you can use the String.Concat
15. Close ViewState
If you do not use the form data to return, then close viewsate. Control to automatically open viewstate this slows down your application speed.
Public Showorderstablepage ()
{
This. Init + = new EventHandler (Page_Init);
}
private void Page_Init (object sender, System.EventArgs e)
{
This. EnableViewState = false;
}
16. Using pagination
. NET application paging has the advantage of application efficiency. Each time you try to display a small amount of data, this speeds up the page display. Please be careful with mixed caching, do not set all data in the buffer.
17. Use appoffline.htm when updating applications
I really hate asp.net default error messages. I'm so happy if I never see the error messages again. Make sure your users don't see it, either. Use appoffline.htm to replace it.
18. Controls use ControlState without using ViewState
19. Using the finally method to reclaim resources
If you use a lot of database connections and access files in your application, make sure to close them after you run out.
Finally block is the last execution in the program, so the code in this area will be sure to be executed, the closing code must be executed in this method block
20. Please do so in strict accordance with the above methods