How to override the @section in MVC Razor

Viewed 1611

Please help me to fix this issue. I have two files BaseLayout.cshtml and the second one is ExtendedLayout.cshtml file for overriding the base content of HTML CSS. I need to run the extended section of extendedLayout.cshtml file if same section is present in override otherwise base would work. Same as OOPS override concept.

Base Layout CSS Code

@section HeadCssSection {
   @*Base Layout CSS *@
   @Styles.Render("~/Content/BaseCSS")
   @RenderSection("HeadCssSection")

}

Extended Layout CSS Code

@section HeadCssSection {
    @Styles.Render("~/Content/ExtendedCSS")
    @RenderSection("HeadCssSection") 
}

Please help me to fix this issue

2 Answers
Related