I cannot name the web service method from Ajax using POST and GET.
At first, only POST will work, and GET will result in this error:
{"Message": "An attempt was made to call the \ u0027getData \ u0027 method using a GET request that is not allowed.", "StackTrace": "at System.Web.Script.Services.RestHandler.GetRawParams (WebServiceMethodData methodData, HttpContext context) \ r \ n
in System.Web.Script.Services.RestHandler.ExecuteWebServiceCall (HttpContext context, WebServiceMethodData methodData) "," ExceptionType ":" System.InvalidOperationException "}
I fixed this by adding this attribute: [ScriptMethod(UseHttpGet=true)]but now GET is causing this error:
{"Message": "An attempt was made to call the \ u0027getData \ u0027 method using a POST request that is not allowed.", "StackTrace": "at System.Web.Script.Services.RestHandler.GetRawParams (WebServiceMethodData methodData, HttpContext context) \ r \ n
in System.Web.Script.Services.RestHandler.ExecuteWebServiceCall (HttpContext context, WebServiceMethodData methodData) "," ExceptionType ":" System.InvalidOperationException "}
So is it true that you can only use POST or GET, not both of Ajax? Does anyone know why this is happening or is there a workaround?
Thanks in advance!