How to make a post request in an MVC application to make an integration to a web services?

    // GET: /Asientos/Create

    public ActionResult Create()
        return View();

    // POST: /Asientos/Create

    public ActionResult Create(Asientos asientos)
        if (ModelState.IsValid)
            return RedirectToAction("Index");

        return View(asientos);
asked by Ramon Pereyra 05.08.2016 в 16:05

1 answer


If I understood correctly you need to invoke using jquery a controller action passing the data by POST, if so, you could implement

Passing JSON objects to Action Methods MVC4?

look at the article as it defines the json that it sends in the data of the $ .ajax so that model binding maps this with the properties of the class that you define per parameter.

The important thing is how to define the $.ajax in client code

var obj = { .. }; //aqui json equivalente a la clase que defines como parametro del action
       url: '@Url.Action("Create","NombreCtrl")',
       type: "POST",
       cache: false,
       dataType: "json",
       contentType: "application/json; charset=utf-8",
       data: JSON.stringify(obj),
       success: function (data) {
      error: function () {

This one explains a little more step by step

Calling ASP MVC Controllers from jQuery Ajax

answered by 06.08.2016 в 06:18