返回一个 Json

动作结果可以返回 Json。

1.Ronurning Json 在 ActionResult 中传输 json

public class HomeController : Controller
{
    public ActionResult HelloJson()
    {
        return Json(new {message1="Hello", message2 ="World"});
    }
}

2.Returning Content 在 ActionResult 中传输 json

public class HomeController : Controller
{
    public ActionResult HelloJson()
    {
        return Content("Hello World", "application/json");
    }
}