Rendering section from partial view using Razor Vi

2019-06-15 04:34发布

问题:

I have rendering a section in the bottom master layout. This is typically section to render javascript at the bottom of the page when it renders. Defining that section in View and _partial views. When page renders, it renders section from page view but not from the _partial view.

How it is possible to render a section defined in _partial view to main layout?

回答1:

You can use Html.RenderAction/Html.Action or use helpers like demonstrated here: https://stackoverflow.com/a/5433722/290343