RenderSection with partial view

In the _Layout.cshtml file, I have such a @RenderSection("head", false) method.

In partial form, UploadForm.cshtml I have the code below.

When I launch the web application, the head section is not displayed. How to solve this problem?

 @section head { <script type="text/javascript"> //skip </script> } 
+6
source share
1 answer

You can call RenderSection only between two views / layouts that are directly related. From what you are saying, it looks like your page structure looks something like this:

UploadForm (section defined here) -> UnknownView -> _Layout (RenderSection is called here)

In this situation, you will need to substantially redefine and display 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

+8
source

Source: https://habr.com/ru/post/908697/


All Articles