ASP.NET Web Service returns IndexOutOfRangeException with arguments

I have the following web service:

[ScriptService]
public class Handler : WebService {

    [WebMethod]
    public void method1() {

        string json = "{ \"success\": true }";

        System.Web.HttpContext.Current.Response.Write(json);

    }

    [WebMethod]
    public object method2(Dictionary<string, object> d) {

        Dictionary<string, object> response = new Dictionary<string, object>();

        response.Add("success", true);

        return response;

    }

}

The first method takes a traditional html form entry, and the response writes a JSON string to the page. The second method takes a JSON value sent via AJAX and returns a serialized object.

Both of these methods work fine on their own, but when they are combined in the same web service, I get this error when calling method1:

System.IndexOutOfRangeException: Index was outside the bounds of the array.

When I remove the arguments to method2, they work.

Can anyone guess why this is happening?

Edit:

2. , . , , , , . , , , ajax, . . , .

+3

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


All Articles