Reputation: 13574
I am fetching the last five added products like following :-
var products = pe.Products.OrderByDescending(p => p.Id).Take(5);
Now, I want to pass the above data as a Json in the following format :-
[{"content": "<div class='slide_inner'><a class=' continues... ","content_button": "<div class='thumb'><img src=' coninues... "
}]
Upvotes: 0
Views: 280
Reputation: 2763
From your Controller
, you can return a JsonResult as the result of your action:
return Json(products)
Behind the scene, your Product
collection will be serialized in a json string by the JavaScriptSerializer.
Upvotes: 2