views:

121

answers:

1

I have a .aspx page with some Webmethods that I use for jQuery ajax calls.

[WebMethod]
public static string HelloWorld(string s) {
    return "Hello"+ s;
}

And call this with Url: /ajax/Test.aspx/HelloWorld

I wonder if it is possible to route this method to another url like /ajax/helloworld/?

+1  A: 

Currently, WebMethods don't work transparently with the Routing framework. There is a work around. You have to access the PageMethods directly by doing the following in your javascript:

PageMethods.set_path('/the/path/to/your/page.aspx');
PageMethods.YourMethod(params, onSuccess, onFailure);

I hope this helps.

iman1003
Excellent! Thanks for the fix.You don't have to specify the full path. PageMethods.set_path('page.aspx'); works just fine.
Lone Coder