RenderAction in Content Page causing Layout not to render

I’ve noticed an issue where calling @Html.RenderAction() from a ContentPage causes the layout not to be rendered. It’s fine when called from a ViewPage.

I’ve tested this in the RazorRockstars project using the following:

<div style="height:100px;overflow:hidden">
  @Html.RenderAction("/rockstars/aged/62")
</div>

I’ve tested this in a few pages:

  • /Views/Shared/MenuDead.cshtml - renders fine, layout present
  • /stars/alive/Grohl.cshtml - page renders without layout.
  • /default.cshtml - page renders without layout.

Can you advise if this is by design or if there is an alternative/workaround to RenderAction?

This should now be resolved from this commit which is available from v4.0.61 that’s now available on MyGet.

2 Likes