0

I have a Ajax-request to my WebService:

JS:

$.ajax(
{
    type: "POST",
    url: "GetProcess.asmx/GetProcessID",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    async: true,
    success: function (response) {
//much code here, not needed here

CodeBehind(GetProcess.asmx):

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class GetProcess : System.Web.Services.WebService
{

    [System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public static Classes.Progress GetProcessID()
    {
        Classes.Progress progress = new Classes.Progress();
        //Alot of code here also. But i dont think this has todo anything with my problem.
    }   
}

A little part of the error, full can be find here: http://pastebin.com/z3wmFX3P

[ArgumentException]: Unknown web method GetProcessID.
Parameter name: methodName
   at System.Web.Script.Services.WebServiceData.GetMethodData(String methodName)
   at System.Web.Script.Services.RestHandler.CreateHandler(WebServiceData webServiceData, String methodName)
   at System.Web.Script.Services.RestHandler.CreateHandler(HttpContext context)
   at System.Web.Script.Services.RestHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
   at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
   at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
   at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Actually i dont see why it has problems with it ?

DatRid
  • 1,169
  • 2
  • 21
  • 46

1 Answers1

1

The problem is that your web method is declared as static. It is not allowed - by design in web methods in web services should be instance methods. So it should be:

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public Classes.Progress GetProcessID()
Andrei
  • 55,890
  • 9
  • 87
  • 108
  • Wow thanks ... Seems like i needed it in the aspx-side bevor i migrated it into a webservice, didnt knew static isnt allowed. Thanks!! – DatRid Apr 14 '14 at 13:43