views:

976

answers:

1

I am building a dynamic partial load asp.net page, I would like to use jQuery to call page methods or web service to retrieve the content HTML.

page methods or web service, performance wise, which way is better?

If I call page method, on the server side, does the page go through full lifecycle?

Is there any good resources help me to better understand page method?

+9  A: 

You can call PageMethods and Web Services without needing a ScriptManager control (which generates the JavaScript proxy objects that allow you to use familiar syntax to call web services and page methods).

Article on using jQuery to directly call ASP.NET AJAX page methods

Article on using jQuery to Consume ASP.NET JSON Web Services

Here's an MSDN article from 2007 on Web Services and Page Methods. Looking briefly through it, it seems to still be relevant to how they work / what you need to do to get them to work today.

Performance wise:

You might expect page methods to offer better performance than Web services. After all, to resolve Web service calls, the ASP.NET runtime has to parse SOAP packets. This, however, isn't exactly true. ASP.NET AJAX installs a tailor-made HTTP handler (see Figure 3) that intercepts all ASMX requests. Requests with a /js suffix are processed differently, working directly with the JSON payload and Web service method. As a result, no SOAP is involved whatsoever and the body of the request simply contains the JSON stream of input arguments. For non-AJAX requests, the new HTTP handler just delegates the call back to the original ASP.NET handler that understands SOAP.

In response to the Page Lifecycle, Page Methods do not go through the server-side Page LifeCycle (there is also a client-side Page Lifecycle too).

Russ Cam
hey @Russ same article again!
TheVillageIdiot
@TheVillageIdiot - I wasn't expecting it to come up again so soon!
Russ Cam