This property does not do exactly what it says. "Gets or sets a value that indicates whether public static page methods in an ASP.NET page can be called from client script. " is incorrect. You are still able to invoke "pagemethods" even when EnablePageMethods is set to false. The only thing that this property does is determine if a javascript proxy class will be generated for the service. You can still invoke the page methods using xhr or some other js lib ( i am testing with jquery).
I looked in the script manager expecting to see the script manager subscribing to one of the page events to handle the page method requests. Didnt see anything there, instead I found in System.Web.Handlers.ScriptModule. Maybe should change the doc or update the code to check. Looks like it would be a small code change.
private void OnPostAcquireRequestState(object sender, EventArgs eventArgs)
{
HttpApplication application = (HttpApplication)sender;
HttpRequest request = application.Context.Request;
if ((application.Context.Handler is Page) && RestHandlerFactory.IsRestMethodCall(request))
{
// Change to check EnablePageMethods property.
ScriptManager scriptManager = ScriptManager.GetCurrent(application.Context.Handler as Page);
if (scriptManager == null || !scriptManager.EnablePageMethods)
{
return; // Exit and process page as normally
}
// End change
WebServiceData data = WebServiceData.GetWebServiceData(HttpContext.Current, request.FilePath, false, true);
string methodName = request.PathInfo.Substring(1);
WebServiceMethodData methodData = data.GetMethodData(methodName);
RestHandler.ExecuteWebServiceCall(HttpContext.Current, methodData);
application.CompleteRequest();
}
}