Can I route the web method?

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

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

And name it with Url: /ajax/Test.aspx/HelloWorld

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

+4
source share
1 answer

WebMethods currently does not work transparently with the routing infrastructure. Works. You should access PageMethods directly by doing the following in your javascript:

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

Hope this helps.

+3
source

Source: https://habr.com/ru/post/1302217/


All Articles