控制器可以完全替代http处理程序吗?
答
肯定的:
public ActionResult Index()
{
return Content("No view involved here", "text/plain");
}
或:
public ActionResult Index()
{
return File("test.pdf", "application/pdf");
}
或:
public ActionResult Index()
{
return Json(new { foo = "bar" });
}
在所有这些例子中,没有涉及视图。该控制器充当一个HTTP处理程序。