How to check if a content section is provided in a RenderSection in ASP.NET MVC 3

Can I check for the presence of the provided content section when using the RenderSection helper in ASP.NET MVC 3?

For instance:

@RenderSection("RightCrumbContentArea", required: false) 

If not specified above, I want to create different content.

+4
source share
1 answer

Perhaps as far as I know.

Try using the following code:

 @if (IsSectionDefined("RightCrumbContentArea")) { @RenderSection("RightCrumbContentArea") } else { <span>poo</span> } 
+8
source

All Articles