I have a webmethod like this:
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public static string test(string Name, int? Age)
{
return "returned value";
}
And the ajax call :
$.ajax({
type: "GET",
url: "form.aspx/test",
data: {'Name': "n1", 'Age': 30},
contentType: "application/json; charset=utf-8",
success: function (data) {
console.log(data);
}
});
Without parameters/data it works, but when I try to pass some parameters I get this error:
GET http://localhost:55410/test.aspx/test?Name=n1&Age=30
500 (Internal Server Error)
I think this's the detailed exception:
System.ArgumentException: Unknown web method form.
Parameter name: methodName