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