0

I need to return some json data from controller. Anyone know how to do it?

2 Answers 2

2

Simple. it's called JsonResult

Sign up to request clarification or add additional context in comments.

Comments

1

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"});
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.