PartialViewResult

public ActionResult PopulateFoods()
{
     IEnumerable<Food> foodList = GetAll();
     
    // Renders a partial view, which defines a section of a view that can be rendered inside another view.
    return PartialView("_foodTable", foodVms);;
}

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

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

public PartialViewResult PopulateFoods()
{
    IEnumerable<Food> foodList = GetAll();
    
    // Renders a partial view, which defines a section of a view that can be rendered inside another view.
     return PartialView("_foodTable", foodVms);
}