As we have previously seen, ASP.NET AJAX Page Methods are a great way to return the minimum amount of data required in an AJAX request. But the question remains, just how much bandwidth can you save by using Page Methods rather than UpdatePanels for AJAX operations.
To illustrate this, we are going to create a new web site with two pages. Both pages will submit contact information to a database and display a notification message when the operation is complete. To capture request and response information, I will be using Mozilla FireFox with the FireBug plugin.
The form we will create will look like the following. We will submit the data shown in the second photo for our comparison:
After creating two identical forms using UpdatePanels and PageMethods, we go ahead and submit the data pictured above back to the database. The results are pictured below in the top image for UpdatePanels and in the bottom image for PageMethods:
As you can see, execution times are nearly the same, but the PageMethods version of the form has a slight advantage over it’s UpdatePanel-based counterpart as far as payload size. Now this is an extremely simple example, but it illustrates the bandwidth savings that you can take advantage of by incorporating PageMethods into your application.
The code I used in this comparison can be downloaded here. Don’t forget to change the connection string to match your system.