Call ASP.NET PageMethod/WebMethod with jQuery - returns whole page

If you have tried all that and still get the whole page returned from your pagemethod, you may want to make sure you are not using friendly urls. If you are using them, this trick may help you

Add this line on your js script before you make the call:

PageMethods.set_path(PageMethods.get_path() + '.aspx');

Do you know that Page Methods are working properly? If you use the the ScriptManager do they work?

It sounds like you might be missing a web.config entry. Specifically the HttpModules section.


I encountered this problem again today for a different reason: I had misspelled "application" in

contentType: 'application/json'

And was getting a full-page response instead of a call to the WebMethod.


I was missing one line from my web.config:

<system.web>
  <httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </httpModules>
</system.web>