0
votes

I got this error

System.InvalidOperationException: ManageUser Web Service method name is not valid. at System.Web.Services.Protocols.HttpServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

when I trying to call a webservice method from button click event using ajaxcall

$.ajax() {
    type: "POST",
    url: "RechargeService.asmx/ManageUser",
    //data: "{objUser: " + JSON.stringify(objUsers) + "}",
    data: "{Name:'" + Name + "',Address:'" + Address + "',City:'" + City + "',State:'" + State + "',Pincode:'" + Pincode + "',MobileNo:'" + MobileNo + "',Email:'" + Email + "',Password:'" + Password + "',Parameter:'" + Parameter + "',UserRole:'" + UserRole + "',UserStatus:'" + UserStatus + "'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    async: false,
    cache: false,
    success: function (data) {
        data = JSON.parse(data.d);
        if (data.Sucess) {
            $("#lblMsg").html('Registration done successfully');
            $("#txtEmail").val('');
            $("#txtPassword").val('');
            $("#txtMobileNo").val('');
            $("#txtConfirmPassword").val('');
            $('#myModal1').hide();
            alert("Your registration completed successfully");
        } else {
            alert("Already registered with this email id");
            $("#txtEmail").val("");
        }
    },
    error: function (xhr, status, error) {
        alert(xhr.responseText + " \n " + status + " \n " + error);

        alert("There was an error while processing. Please try again after some time.");
    }
}

Method

[WebMethod] 
Public string ManageUser()
{

}

This code works fine in local after hosting only i get the above error pls help me with this.. Thanks in advance

3
Brackets of jquery ajax are not valid. check jquery ajaxMr_Green
See its works fine in local i mean development environment brackets are fine i checked ... only after hosting i get the above error .. we need to do any change in hosting serverMuthu

3 Answers

1
votes

This can be caused by having null valued parameters in your WebMethod.

For example this:

public string GetDocument(int templateId, int? loginId = null)

...should be changed to this:

public string GetDocument(int templateId, int loginId)
0
votes

There is a missing brackets () in the ajax function that should be Like this

$.ajax({ 
     //Your Code...
});

Try this...

-1
votes

Possible REASON 1: did u add this in above the service class

[System.Web.Script.Services.ScriptService]

Possible Reason 2: Data should have sigle quotes for patameter names as well

data:{'Name':'" + Name + "','Address':'" + Address + "'}