@Html.Action in Asp.Net Core

后端 未结 9 2096
说谎
说谎 2020-11-27 19:25

Where is @Html.Action in Asp.net Core? I can see @Html.ActionLink but not a direct call to an Action as before.

Was it replaced by ViewComp

9条回答
  •  离开以前
    2020-11-27 19:51

    M.R.T2017 said : ... The following examples were successfully tested: ...

    First thanks for your sharing.

    But this overload method may be cause "HTTP ERROR 500" :

    @Html.RenderAction("About")
    

    Because 'controller' maybe lower case controller name, ex. "home", "grid", etc. :

    helper.ViewContext.RouteData.Values["controller"]
    

    You need capitalize the controller name, ex. "grid" -> "Grid", because the controller class name is case-sensitive in Assembly, action name is the same.

    *Visual Studio 2019/NET Core 2.2.

提交回复
热议问题