Calling a PageMethod with ajax from a WebForm within an mvc project

0

I would like to know why this "404 (Not Found)" error is flagging me when I try to call a WebMethod with ajax from a WebForm or aspx, now the detail is that the webform is inside a Mvc project I do not know if it has something to do

I leave the code of how I'm called from the js. Thank you very much in advance.

code js

$.ajax({
            type: "POST",
            data: "",
            url: "../AspNetForms/WebForm1.aspx/MR_Operaciones",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(result){
                alert("todo bien ");
            },
            error: function (result) {

                alert("Algún problema debe haber…");
            }
        });

code in C #:

[WebMethod]
    public static List<object> MR_Operaciones()
    {
        List<object> list = new List<object>();
        try
        {

                    return new List<object>() { "", "listaparametros", "listacontroles" };                    

        }
        catch (Exception ex)
        {
            return new List<object>() { ex.Message };
        }
    }
    
asked by Eliseo Alcantara 26.12.2016 в 18:36
source

1 answer

0

In data it puts the name of the method, and in URL it only leaves the route of the page

$.ajax({
        type: "POST",
        data: "MR_Operaciones",
        url: "../AspNetForms/WebForm1.aspx",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(result){
            alert("todo bien ");
        },
        error: function (result) {

            alert("Algún problema debe haber…");
        }
    });
    
answered by 03.01.2017 в 20:53