RenderSection from partial view
10,711
You can only call RenderSection between two Views/Layouts that are directly related. From what you say it looks like your page structure is something like:
UploadForm (section defined here) -> UnknownView -> _Layout (RenderSection called here)
In this situation you would need to essentially redefine and render the section in your View in the middle.
See: http://blogs.msdn.com/b/marcinon/archive/2010/12/15/razor-nested-layouts-and-redefined-sections.aspx for a clearer explanation
Author by
Tomas
Updated on June 09, 2022Comments
-
Tomas almost 2 years
In
_Layout.cshtml
file I have such method@RenderSection("head", false)
.In partial view
UploadForm.cshtml
I have code below.When I run web app the
head
section is not rendered. How to solve this problem?@section head { <script type="text/javascript"> //skip </script> }