Call RenderSection twice …?

2019-04-19 21:35发布

问题:

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:

Maybe something like:

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

First:
@Html.Raw(result);

Second:
@Html.Raw(result);