In the layout, MVC child actions are called in . However, the the partialView results are not shown in the RenderSection("userProfile", required:false). The Watch window shows the result contains data, though. Thanks.
Controller's Action
[ChildActionOnly]
public ActionResult GetUserProfile()
{
var vm = base.appVM.User;
return PartialView("UserProfilePartial", vm);
}
UserProfilePartial.cshtml
@model myApp.viewModel
@section userProfile{
<div>@string.Format("{0}, {1}", Model.lastName, Model.firstName)</div>
@foreach (var item in Model.Locations)
{
<div>
<ul class="row">
<li class="cell">@item.LocType</li>
<li class="cell">@item.LocName</li>
<li class="cell">@item.UserRole</li>
</ul>
</div>
}
}
Layout.cshtml
<body>
<header>
<div class="content-wrapper">
<div class="float-left">
<p class="site-title">@Html.ActionLink("Home", "Index", "Home")</p>
</div>
@Html.Action("GetUserProfile","User")
<div class="float-right">
@RenderSection("userProfile", required: false)
</div>
@Html.Action("Index", "Menu");
<div class="menu">
@RenderSection("menu", required:false)
</div>
</div>
</header>
@RenderBody()
</body>