我想知道 Controller 是否可以在不涉及 View 的情况下完全替代 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" });
}
在所有这些示例中,都没有涉及 View 。 Controller 充当 HTTP 处理程序。
关于asp.net-mvc - Controller 能完全取代 http handler 的功能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4233388/