ASP.Net MVC Model Binding Complex Object using GET

前端 未结 3 2066
生来不讨喜
生来不讨喜 2021-02-20 17:48

I have a class in my web project:

public class MyClass
{
    public int? Param1 { get; set; }
    public int? Param2 { get; set; }
}

which is a

3条回答
  •  一生所求
    2021-02-20 18:39

    Why are you calling the property "data" in the POST, and "params" in the GET? Both should be called "data".

    $http({
        method: "get",
        url: controllerRoot + "TheControllerMethod",
        data: {   
            myParam: myParam
        }
    }).success(function (data) {
        callback(data);
    }).error(function () {
        alert("Error getting my stuff.");
    });
    

提交回复
热议问题