LcSalazar LcSalazar - 1 year ago 184
Ajax Question

Page_Load is been fired when WebMethod is called through javascript PageMethods

I have an aspx page. I've added a ScriptManager to it, and set

, and created a static method marked as [WebMethod] on the server-side.

I have always worked with WebMethods, and I've never seen this error before.

On javascript, PageMethods is accessible. But when I call my method, the
method is fired, instead of the WebMethod.

I've searched and found other people had this issue as well. But no answers.... Any ideas?


<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager>




public static void Test()


Answer Source

I discovered that the problem on my case is that I'm using friendly URL's. Since PageMethods references the server-side page by its address, there you have the issue. It's been discussed here, on CodePlex:

Apparently there are workarounds for this, but I ended up making a manual ajax call to a generic handler (.ashx).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download