ASP.NET page methods vs web service

13,708

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).

Share:
13,708

Related videos on Youtube

nandin
Author by

nandin

.NET developer

Updated on April 16, 2022

Comments

  • nandin
    nandin about 2 years

    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?

  • TheVillageIdiot
    TheVillageIdiot over 14 years
    hey @Russ same article again!
  • Russ Cam
    Russ Cam over 14 years
    @TheVillageIdiot - I wasn't expecting it to come up again so soon!
  • Ponni Radhakrishnan
    Ponni Radhakrishnan almost 8 years
    @RussCam a follow-up question, Are PageMethods Async, or can they be made Async? I have hit a wall where one PageMethods call (that takes about 4 secondsto return) blocks and prevents other timer-based Page method calls from running as expected.