I would really appreciate a tip here... I've been looking for a solution for 4 hours now...
I have a function like so:
public virtual JsonResult LoadPreviousProductsJson(SearchResultModel rmodel, SearchCriteriaModel cmodel)
I'm trying to send data to this controller like so:
var jsonData = $('#frmSearchResult').serialize();
var stringToPost = JSON.stringify(jsonData);
var jsonData2 = $('#frmSearchProducts').serialize();
var stringToPost2 = JSON.stringify(jsonData2);
$.post('@Url.Action(MVC.Product.LoadPreviousProductsJson())', { rmodel: stringToPost, cmodel: stringToPost2 })
.done(function(data) {....
This results that the objects are Null in the controller...
If I only send 1 Json objectI am succesfull:
$.post('@Url.Action(MVC.Product.LoadPreviousProductsJson())', stringToPost)
.done(function(data) {....
but when I try to send them together, it Always fails...
Only somewhat successful thing I can do is sending the 2 objects as string and read them with Newtonsoft, but here I can't convert the strings to the corresponding objects....
model = Newtonsoft.Json.JsonConvert.DeserializeObject<SearchResultModel>(rmodel);
model2 = Newtonsoft.Json.JsonConvert.DeserializeObject<SearchCriteriaModel>(cmodel);
The above code just fails...