Post multiple parameters to MVC Controller using C#

前端 未结 2 956
星月不相逢
星月不相逢 2020-12-19 14:00

I am posting a json object to an ASP.Net MVC controller with C# code. To keep things simple in this example the object is just a car with make and model properties. Everythi

2条回答
  •  既然无缘
    2020-12-19 14:53

    It is not a problem, make you request like:

    "{\"Make\":\"Ford\",\"Model\":\"Mustang\", \"email\":\"xxx\", \"phone\":\"yyy\" }";
    

    ASP.NET MVC Json binder should be smart enought to bing that correctly for method, like:

    public JsonResult showdata(Car c, string email, string phone)
    

提交回复
热议问题