开发者

Can Controller fully replace what http handler does?

开发者 https://www.devze.com 2023-01-26 06:07 出处:网络
I want to know if controll开发者_Go百科er can fully replace http handler when no view involved. The function looks similar.Sure:

I want to know if controll开发者_Go百科er can fully replace http handler when no view involved. The function looks similar.


Sure:

public ActionResult Index()
{
    return Content("No view involved here", "text/plain");
}

or:

public ActionResult Index()
{
    return File("test.pdf", "application/pdf");
}

or:

public ActionResult Index()
{
    return Json(new { foo = "bar" });
}

In all those examples, there's no view involved. The controller acts as an HTTP handler.

0

精彩评论

暂无评论...
验证码 换一张
取 消