Do you use response. Redirect?
Search for your code as "response. Redirect" and consider replacing it with server. Transfer. This does not incur a new request cost because it avoids any client redirection.
You cannot always simply replace response. Redirect to call server. Transfer, because server. Transfer uses a new handler during the processing stage of execution. Response. Redirect generates the second request. If you need different authentication and authorization, caching, or other targets on the runtime device, these two mechanisms are not equivalent. Response. Redirect causes an additional request to be sent to the server. Response. Redirect also makes the URL visible to the user. This may require a new location of the user's bookmarks in some cases.
Are you using page. ispostback?
Check whether the page. ispostback attribute is used in your page logic to reduce unnecessary processing and avoid unnecessary initialization costs. Use the page. ispostback attribute to execute code conditionally, depending on whether the page is generated in response to a server control event, or whether the page is loaded for the first time.
Are you verifying user input?
Check to verify that the user enters the client to reduce the round-trip of the server. This also provides better feedback to users. For security reasons, ensure that any client verification is praised with the corresponding server verification.
Do you have a clear and strict truth?
Make sure that you use option strict and explicit to reduce unexpected late binding when using Visual Basic. . Net.
- <%@ Page Language="VB" Explicit="true" Strict="true" %>
You can easily search for the findstr.exe file using the regular expression.
- C:\findstr /i /s /r /c:"<%.*@.*page.*%>" *.aspx
- pag\default.aspx:<%@ Page Language="VB" %>
- pag\login.aspx:<%@ page Language="VB" %>
- pag\main.aspx:<%@ Page Language="VB" Explicit="true" Strict="true" %>
- ...
Have you disabled debugging?
Check your web. config file, and make sure that debugging is set to false and check. To make sure that the debugging is set to false. If debugging is enabled, the compiler does not generate optimized code and batch page compilation. You can use findstr.exe in the regular expression to perform a file. ASPX page.
- C:\pag>findstr /i /r /c:"<%.*@.*page.*debug=.*true*.*%>" *.aspx
- login.aspx:<%@ page Language="VB" Debug="True" %>
- main.aspx:<%@ Page Language="c#" Debug="True" %>
You have disabled tracking?
Check your web. config file to make sure that the trail is partially disabled. In addition, please check your. To make sure that the trail is set to false. You can use findstr.exe in the regular expression to perform a file. ASPX page.
- C:\pag>findstr /i /r /c:"<%.*@.*page.*trace=.*true*.*%>" *.aspx
- login.aspx:<%@ page Language="VB" Trace="True" %>
- main.aspx:<%@ Page Language="c#" Trace="True" %>
Are you actively timeout?
Actively adjust settings timeout. Evaluate each page and determine a reasonable timeout. The timeout page specifies a timeout value of 90 seconds in the timeout attribute of machine. config. Server resources are held until the request is processed completely or the execution time is reached, whichever is earlier. In most cases, users do not have to wait for such a long request to complete. They either give up the request completely or send a new request, which further increases the load on the server.
Are you using view status?
Use the following exercise to evaluate how your application uses view status effectively:
When you disable the view status, does it need?
Evaluate each page to determine whether to check whether the status is enabled. View status increases the overhead of each request. Overhead includes increasing the size of page sending to the client, as well as a serialization and deserialization cost. You do not need to view the status under the following conditions:
A page that does not return itself is only used for output and does not depend on Response Processing.
The server controls on your page do not process events. Do you have dynamic or data-bound property values (or they are in the code of each request ).
If you ignore the old data and refill the server to control every page refresh.
Have you taken steps to reduce the size of your view status?
Evaluate the use of the view status on each page. To determine the size of the view status of a page, you can enable tracing to see how each control uses it. View status is disabled based on the control.
Do you use server controls?
Use the following exercise to review how your ASP. NET application uses server controls effectively:
When you use server controls, Do you not need them?
Evaluate the use of your server controls to determine whether they can replace text that has lightweight HTML controls or may be static. You may change a server control in the following situations:
The data displayed in the control is static, for example, a tag.
You do not need to use programming to access server-side control.
The control displays read-only data.
You do not need to control the status during the process.
Do you have a deep level of server control?
Deeply nested server controls composite layers to build Control tree costs. You can use response. Write or create a custom control for the content to be presented. The control and control layers to be determined to track the page.
Do you want to access data from your ASPX page?
Most ASP. NET applications require some form of data access. The performance and scalability of data access are shared. Review the following questions to help improve page-level data access for your applications:
What result set does your page contain?
Determine your application fields, and display large result sets and consider paging results. A large result set is displayed to users, which can significantly affect the performance.
When you use a dataset, can you use datareaders?
If you do not need to cache data, the exchange data between the layer and the layer or the data is bound to a control and you only need to enter the data, read-only access the data, and then use datareader instead.
Can you use data binding?
Use the following exercise to review the data binding usage of the Code:
Do you use page. databind?
Avoid calling page. databind and binding each control separately to optimize your data binding. The called page. databind recursively calls the databind of the control on each page.
Do you use databinder. eval?
The use reflection of databinder. Eval affects performance. In most cases, databinder. Eval is called from a page multiple times, so implementing alternatives provides a great opportunity to improve performance.
Avoid the following:
- <itemtemplate>
- <table><tbody><tr>
- <td><%# DataBinder.Eval(Container.DataItem,"field1") %></td>
- <td><%# DataBinder.Eval(Container.DataItem,"field2") %></td>
- </tr></tbody></table>
- </itemtemplate>
Use Explicit conversions. It provides better performance and avoids reflection costs. Cast as a datarowview container. dataitem, if the data source is dataset.
- <itemtemplate>
- <table><tbody><tr>
- <td><%# ((DataRowView)Container.DataItem)["field1"] %></td>
- <td><%# ((DataRowView)Container.DataItem)["field2"] %></td>
- </tr></tbody></table>
- </itemtemplate>
Cast as a string container. dataitem if the data source is an array or an arraylist.
- <itemtemplate>
- <table><tbody><tr>
- <td><%# ((String)Container.DataItem)["field1"] %></td>
- <td><%# ((String)Container.DataItem)["field2"] %></td>
- </tr></tbody></table>
- </itemtemplate>
Does the ASPX page call unmanaged code?
Use the following exercise to review code interoperability usage:
Have you enabled the call to the sta COM component aspcompat?
Make sure that the aspcompat page-level attribute settings of the sta COM component are called on any page. This instructs ASP. NET to use the stathread pool thread to execute the request for the current page. By default, ASP. NET uses the MTA thread pool to process page requests. If you are using the sta component, the component is bound to the created thread. This will cause a thread sta object from the thread pool to be created for expensive thread switching.
Do you create the construction of the sta COM component on the page?
Check your webpage to ensure that you have not created the construction of the sta COM component on the page. Create page_load, page_init, or other events in the sta component, instead. The page constructor is always executed on an MTA thread. When the sta COM component is created from an MTA thread, it creates the stathread of the sta COM component on the host. All instances created by the execution unit thread component from the MTA thread in the same thread (host Sta. This means that even if all users have references to their own COM component instances, all calls to these components serialize this thread and only one call is executed at the same time. This will effectively bottleneck a separate thread page and cause significant performance degradation. If you are using the aspcompat attribute, these events run a thread using the stathread pool, which hits the thread due to a smaller performance result.
Are you using the server. Create object?
Avoid using server. Createobject and components that are bound to you earlier as much as possible during compilation. Server. Createobject is bound later to provide backward compatibility. Search your code library to see if this routine is used as an alternative, create an interoperability assembly, and take advantage of early binding.
Have you reviewed the settings in machine. config?
Use the following exercise to review your application deployment plan:
Adjust the appropriate thread pool?
Adjust the CLR thread pool appropriately to improve performance. Before deploying an application, make sure that the thread pool has been adjusted to your application.
Memory limit configured properly?
Configure ASP. NET memory limits to ensure optimal ASP. NET cache performance and server stability. In IIS 5.0, or when you use the ASP. NET Process Model in IIS 6.0, configure the memory limit in machine. config. In IIS 6.0, you use the memory limit configured in the iis mmc snap-in.
Do you delete unnecessary httpmodules?
Including httpmodules, you do not need to add additional overhead ASP. NET Request Processing. Check whether you have deleted or commented out the machine. config of the unused httpmodules.