ContentResult 型別

public ActionResult Hello()
{
    // Returns a user-defined content type, in this case a string.
    return Content("hello world!");
}

Action 方法通常返回一個稱為操作結果的結果。ActionResult 類是所有操作結果的基類。ActionInvoker 根據操作方法執行的任務決定返回哪種型別的操作結果。

可以明確指出要返回的型別,但通常沒有必要。

public ContentResult Hello()
{
    // Returns a user-defined content type, in this case a string.
    return Content("hello world!");
}

你可以在這裡瞭解更多 :Asp.Net Mvc:ContentResult 與 string