ASP MVC View Content as JSON
- by Craig
I have a MVC app with quite a few Controller Actions that are called using Ajax (jQuery) and return partial views content which updates a part of the screen. But what I would rather do is return JSON something like this.
return Json(new {
Result = true,
Message = "Item has been saved",
Content = View("Partial")
});
Where the HTML is just a property of the Json. What this means is I need to retrieve the HTML that is rendered by the View method. Is there any easy way to do this, a few examples I have seen are quite convoluted.
Edit: This question was originally for ASP.NET MVC 1, but if version 2 makes it easier I would like to hear the answer.