14
votes

I have an ASP.NET-MVC3-Layout and use the RenderSection function:

@RenderSection("BackLink", required: false)

How can I call this function twice? I want to render a defined section at multiple places in my layout.

If I use @RenderSection() more than once I get an error.

1

1 Answers

25
votes

Maybe something like:

@var result = RenderSection("BackLink", required: false).ToHtmlString();

First:
@Html.Raw(result);

Second:
@Html.Raw(result);