Reputation: 39
I need to return some json data from controller. Anyone know how to do it?
Upvotes: 0
Views: 66
Reputation: 218798
You could do this manually:
public ActionResult MyAction() {
return Content("this is a string literal, which can be HTML, XML, JSON, etc.");
}
But I think I remember an actual JSON return object before, though I've never used it. Something like:
public ActionResult MyAction() {
return Json(new {thing1="first thing", thing2="second thing"});
}
Upvotes: 1