I need to add some css and js in <head>
of serval pages,but not
all pages.
So I using a section in _Layout.cshtml of <head>
:
@RenderSection("JSANDCSS", false)
What's more ,the css and js in these pages are all the same.So I use a Parital Views named 'Others.cshtml' to make it more convenient:
@section JSANDCSS{<script src='/js/pages.js'></script><link href='/css/pages.css' rel='stylesheet'>
}
Finally,when I use
Html.RenderPartial("Others.cshtml");
in razor page,html in "Others.cshtml" can render correctly,but only the section can't be render.
I googled and found someone said Section in Partial Views can not be render for certain in ASP.NET MVC3,but he has no solution.However,I don't know if .net core is the same with this problem.
Whatever,how can I solve this problem in .net core?For I don't want to edit all of the page when I edit the @section JSANDCSS
Thank you.