Prefer Web Services to Page Methods in Atlas Server Side Implementation
Dflying | 03 April, 2006 01:42There are two ways to expose a server side method to the client side Atlas controls, Web Service and Page Method. The one I prefer is the Web Service way.
The important thing everyone should keep in mind is that the Page Method calls and Web Service calls work very differently from each other. In the Web Services case, a simple call is made, passing only your method parameters as data. On the other hand, a call to a Page Method is much more heavy weight, for it includes the content of ALL your form fields, also the large ViewState. On the server, it works almost the same as a PostBack. That is, all your server controls receive their states before the method is called. That is what makes it possible to access your controls' values from the method.
So my recommendation is to use Page Methods only when you need this functionality (the ability to access server controls), and you should use Web Services which don't directly depend on your page as much as possible.
You may get the HTTP traffic watcher and debug tool Fiddler at http://www.fiddlertool.com/fiddler/, which is very useful for you to monitor the real network traffics of your page.
Here is the server side code which simply returns server’s current DateTime.
[WebMethod] public DateTime GetCurrentDateTime() { return DateTime.Now; }
Then let’s make it run a Web Service and a Page Method. Open Fiddler and get following results:
Web Service
Page Method
You may find the Content-Length of the Web Service way is 0 while the Page Method way is 1718.
Posted in
Atlas.
Comment: (0).
Trackbacks:(92).
Permalink
«Next post |
Previous post»




