Post a json object to mvc controller with jquery and ajax

后端 未结 3 1230
傲寒
傲寒 2020-12-18 17:57

I am trying to submit some values from a form to my mvc controller.

Here is my controller:

 //Post/ Roles/AddUser
    [HttpPost]       
    public Ac         


        
3条回答
  •  难免孤独
    2020-12-18 18:52

    instead of receiving the json string a model binding is better. For example:

    [HttpPost]       
    public ActionResult AddUser(UserAddModel model)
    {
        if (ModelState.IsValid) {
            return Json(new { Response = "Success" });
        }
        return Json(new { Response = "Error" });
    }
    
    
    

提交回复
热议问题