简体   繁体   中英

Unknown web method Delete_Local_ABC. Parameter name: methodName in ASP.NET app

I have been getting this error on my following code, which basically initiates the POST request as ABC.ascx

var ABCid = $(aTag).data('id');
        $.ajax({
            type: "POST",
            url: "WebMethods.aspx/Delete_Local_ABC",
            data: "{'id':'" + ABCid + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: successdelete_ABC,
            error: Errordelete_ABC
        });
    }

WebMethods.aspx.cs

[WebMethod]
public static int Delete_Local_ABC(string id)
{
    ABC objABC = new ABC();
    objABC.ABC_ID = Convert.ToInt32(id);
    // call business manager
    try
    {
        BusinessManager businessManager = new BusinessManager();
        businessManager.ManageABC(objABC, OperationTypes.Validate);
        return 1;
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

and I am calling following method in BusinessManager.cs

....
case OperationTypes.Validate: 
                    obj.deleteLocalABC();
                    break;
...

and ABC.cs

public bool deleteLocalABC()
        {
            string query = "DELETE FROM TBL_ABC WHERE ABC_ID ='" + this.ABC_ID + "'";
            _dbManager.executeQuery(query);

            return true;
        }

I have tried all the solutions available online but nothing is working. This code works perfectly with Visual Studio but not on main deployment.

Use

[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]

instead of just [WebMethod] . I hope your method work fine after that addition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM