开发者

Can Controller fully replace what http handler does?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜