Invalid method "methodname" server

I have a weird error when calling WebService / C # from javascript.

Failed to execute GetGoogleToken server method. No details, no stacktrace. On the server, I set a breakpoint - everything works smoothly, and I save the line (what could be easier?)

Also, the method works great when I call it using the browser testing environment.

Here is a way:

[WebMethod]
public string GetGoogleToken(string login, string password)
{
    try
    {
        string token = string.Empty;
        if (!String.IsNullOrEmpty(login) && !String.IsNullOrEmpty(password))
        {
            ContactsService service = new ContactsService("...");
            service.setUserCredentials(login, password);
            token = service.QueryAuthenticationToken();
        }

        return token;
    }
    catch (Exception ex)
    {
        // no errors happening on server side
        throw new ApplicationException("Error in GetGoogleToken", ex);
    }
}

My class attributes:

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

my javascript:

Namespace.WebServices.ContactsImport.GetGoogleToken(login, password, ImportGoogle.authenticated, OnAjaxRequest_Error);

I also noticed that an error occurs before the server returns. (e.g. I have a breakpoint)

+3
source share
1 answer

- html- runat = "server" , Javascript-. , javascript Microsoft , -.

+3

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


All Articles