Stewart Hou
Stewart Hou

Reputation: 769

Why RenderBody() not working inside code

Why in a ASP.NET MVC Razor Layout Page

@if (true)
{
    <div>@RenderBody()</div>
}

works, However the code below does not?

@if (true)
{
    RenderBody();
}

If will execute the codes that RenderBody() suppose to render, but output nothing in the final result.

Upvotes: 0

Views: 2303

Answers (1)

JWP
JWP

Reputation: 6963

Try this.

@if (true)
{
  @RenderBody();
}

Upvotes: 1

Related Questions