AJAX: describes how to improve AJAX performance.
In Web forms, AJAX is used to call the server method from the client (through JavaScript), while XMLHttpRequest is called within AJAX. I tested some AJAX functions implemented in different ways. In addition, I also monitored and analyzed the performance and lifecycle of AJAX calls. As a result, I found some serious problems when using AJAX in Web forms. However, I also found a solution to these problems. In this article, I want to analyze this problem and its corresponding solutions.
Ii. performance problems encountered when using AJAX
For every AJAX call, we need to create an instance of classes containing AJAX methods. In addition, if we use the new keyword at the class level, we also need to create instances for fields, attributes, and other class-level variables.
Iii. Implementation Scheme
I created a project that contains two Web forms: WebForm1.aspx and WebForm2.aspx, and a class of Student. vb. Both code-behind pages use an AJAX function getData () and a public variable of the Student type. With the help of the MXLogger class, I recorded the execution process of each stage.
Note: The AJAX function GetData () of Webform2.aspx is shared, but it is not shared in WebForm1.
'Student. vb Public Class Student Sub New () MXLogger. AddLog ("From Student. Constructor ") End Sub Dim _ Name As String Public Property Name () As String Get Return _ Name End Get Set (ByVal Value As String) _ Name = Value End Set End Property End Class
'Webform1. aspx. vb Public Class WebForm1 Public Student As New Student Sub New () MXLogger. AddLog ("From WebForm1.Constructor ") End Sub _ Public Function getData () As String MXLogger. AddLog ("From WebForm1.Ajax. getData ()") Return "I m a Non Shared Function" End Function End Class 'Webform2. aspx. vb Public Class WebForm2 Public Student As New Student Sub New () MXLogger. AddLog ("From WebForm2.Constructor ") End Sub _ Public Shared Function getData () As String MXLogger. AddLog ("From WebForm2.Ajax. getData ()") Return "I m a Shared Function" End Function End Class |
[1] [2] Next page