Note: ASP.NET application performance optimization

xiaoxiao2021-03-06  58

1, use ISPostback in Page_Load

2, Session and Server Control (server-side control), viewstate should try to use the server-side control overhead, so we should use less, but considering the requirements of the program function, it is unlikely to use very little, Therefore, if it is not necessary, set the ViewState status of the server-side control to false.

3, do not use the Exception control process

E.g:

Try {

Result = 100 / NUM;

} catch (exception e) {

Result = 0;

}

The correct way is

IF (NUM! = 0) Result = 100 / Num;

Else Result = 0;

The reason is that Exception takes up a lot of resources, and it can not be used.

4, disable VB and JScript dynamic data types

<% @ Page language = "vb" strake = "true"%>

5, use stored procedure data access

Put the frequently used queries during the stored procedure. This is also conducive to packaging logic.

6, read-only data access Don't use DataSet

Use SqlDataReader instead

SqlDataReader is Read-Only, Forward-Only

7. Close the Debuy mode of the ASP.NET is set in WebConfig, and it is generally not required to be debugged in WebConfig. You can turn off the debuy mode.

Debug = "True">

8, use the ASP.NET OUTPUT CACHE buffer data

8.1 page buffer

<% @ OutputCatch%>

Duration buffer time, unit seconds, how long does it take to request DURATION = 60

VarybyParam buffer based VarybyParam = "cityname" cityname is the parameter name of the page POST

E.g:

A page of a weather query, select a city, page display to the city's current weather.

Page Add <% @ OutputCatch Duration = 60 VarybyParam = "CityName"%>

Represents the same request (POST) for each cityName, will be reapplying after 60 seconds.

Here, use a remote web service to get a city's weather, the current Web Service is relatively long, such as this web service takes half a second to get the result, so if you do not join, hundreds of people are accessed at the same time. Waiting time is unacceptable, so add cache.

Since the weather in each city is saved, this is an array, and VarybyParam is the subscript of this array. It can also be a multi-dimensional array.

Fragment buffer

Data buffer

Cache object

转载请注明原文地址:https://www.9cbs.com/read-113585.html

New Post(0)