1

I'm sending a json in the view with an ajax request and need to use it in the controller. But this json has dynamic parameters that means somethings it could have 10 or more properties so I cannot define a model. How can I get access to the properties in the controller?

Ajax request:

$.ajax({
          url: 'SaveSub',
          type: 'POST',
          contentType: 'application/json',
          data: JSON.stringify(data),                        
          error: function (jqXHR, exception) {
              alert('Error.');
          }
});

Json ex1:

"{"ID":2,"WareCost":"Cost","Driver":6,"Capri": 5622.599999999999, "Polo":14993.6, "Depor":937.1,"PorCost":62}"

Json ex2:

"{"ID":2,"WareCost":"Cost","Driver":6, "Depor":937.1,"Sands":937.1,"Leg": 5622.599999, "Polo":14993.6, "Depor":937.1,"PorCost":80}"

Controller:

public ActionResult SaveSub(object model) 
{
}
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.