PartialView 在cshtml 用 @Html.Action() 和 @Html.Partial() 的区别

controller cs

public ActionResult AdvanceSearchForm()
        {
            SearchCriteriaModel model = new SearchCriteriaModel { SearchInAll = true };
            return PartialView("AdvanceSearchForm", model);
        }

用法1 cshtml

@Html.Action("AdvanceSearchForm")

这种访问方式,先会去controller 执行AdvanceSearchForm 这个action ,然后再回到cshtml

用法2 cshtml

@Html.Partial("AdvanceSearchForm",new SearchCriteriaModel { SearchInAll = true })

这种访问方式,不会去controller ,而是直接到cshtml

原文地址:https://www.cnblogs.com/lavenvsxiaoye/p/4622801.html