如何从Web API中的带有jQuery Ajax的对象类型参数的Post方法获取数据

时间:2018-10-10 20:48:28

标签: asp.net-web-api

大家好,我在ajax方法和Web API中的控制器代码中遇到数据获取问题。实际上我想从post方法中获取数据,在此方法中我传递了44个Input参数,但是我没有从控制器中得到任何东西代码令人失望

 [HttpPost]
    [Route("api/tblProducts/CustomizeProduct")]
    [ResponseType(typeof(IEnumerable<GetFilterProducts_Result>))]
    public IHttpActionResult GetCustomizeProduct([FromBody] CustomProductInput CuP)
    {

        string A= CuP.color1;
        string B = CuP.size1;
        IEnumerable<GetFilterProducts_Result> tblSmlrProduct = db.GetFilterProducts( CuP.size1, CuP.size2, CuP.size3, CuP.size4, CuP.size5, CuP.size6, CuP.size7, CuP.size8, CuP.size9, CuP.size10, CuP.size11, CuP.size12, CuP.size13, CuP.size14, CuP.size15, CuP.size16, CuP.size17, CuP.size18, CuP.size19, CuP.size20, CuP.color1, CuP.color2, CuP.color3, CuP.color4, CuP.color5, CuP.color6, CuP.color7, CuP.color8, CuP.color9, CuP.color10, CuP.color11, CuP.color12, CuP.color13, CuP.color14, CuP.color15, CuP.color16, CuP.color17, CuP.color18, CuP.color19, CuP.color20, CuP.price1, CuP.price2, CuP.categoryId,CuP.discountPercentage1,CuP.discountPercentage2).AsEnumerable();

        if (tblSmlrProduct == null)
        {
            return NotFound();
        }

        return Ok(tblSmlrProduct);
    }

这里所有参数都具有来自ajax调用的值,并且存储过程仍然工作正常,但仍然没有任何数据,请帮助我

0 个答案:

没有答案