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);
}