Several Methods for Improving ASP. NET Website Performance

Source: Internet
Author: User

Http://www.codeproject.com/KB/aspnet/aspnetPerformance.aspx:

1. Http Compression

HTTP compression is usually used to compress the page content returned from the server. It compresses HTTP requests and responses, which will greatly improve the performance. My project is developed based on window Server 2003. You can refer to this article.Article.

2. invalidate viewstate

Viewstate allows the page to remain in the client state, which is not different from Cookie or server memory. View state stores data in a hidden domain. It is certain that this is a very powerful feature, but its disadvantage makes the page size and memory in the server increase.

Therefore, we should avoid using viewstate, especially the DataGrid Control and viewstate to load the status of all table data. Remove it to reduce the page size.

3. Change the Web. config file

A. Use Page cache:

This will save your page for a certain period of time, and the page can be loaded more quickly. But remember, if your page data is updated frequently, it is not suitable for using the page cache.

<Caching> <outputcachesettings> <outputcacheprofiles> <Add name = "cached" Duration = "600" varybyparam = "NONE" enabled = "true"/> </outputcacheprofiles> </outputcachesettings> </caching>

B. Remove unnecessary httpmodule from web. config:

<Add name = "scriptmodule" type = "system. web. handlers. scriptmodule, system. web. extensions, version = 3.5.0.0, culture = neutral, publickeytoken = Taobao "/> <remove name =" windowsauthentication "/> <remove name =" passportauthentication "/> <remove name =" anonymousidentification "/> <remove name =" urlauthorization" /> <remove name = "fileauthorization"/>

C. Disable tracking:

<Trace enabled = "false" pageoutput = "false"/>

D. Enable Automatic saving of profiles when user membership is used:

<Profile enabled = "true" automaticsaveenabled = "false"/>

E. Set the debugging status to false:

<Compilation DEBUG = "false">

4. Improve cache dependency:

Three methods of cache dependencies can be used:

1. caching dependencies for traditional cache items;

2. caching dependencies on the file;

3. caching dependecies on SQL;

You should choose the best strategy to adapt to your applicationProgramHere is an example of cache dependency on a file.

5. Optimize the CSS style sheet:

It is very important to clear CSS styles. It is useless to remove them.CodeIt can improve page loading efficiency. In the project, you can use tools to compress the size of the style sheet, and you can use CSS online compression tools to compress the size of CSS code.

6. Optimize JavaScript code:

JavaScript code can be optimized using the JS online compression tool.

7. js and CSS file location:

Place the CSS file in the header of the page as much as possible, and put the JS file at the bottom of the page as much as possible.

8. If possible, replace server. Transfer () with response. Redirect ()

This will load the page faster, because it is only in the post form, instead of refreshing the entire page.

9. Use the client script for verification:

This prevents PostBack backhaul.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.