How to add head section in a page that has layout template

Tags: css,,,

Problem :

I need add specific css file for my page "Index.cshtml" that has layout "_BasicLayout.cshtml".

In ASP.NET WebForms I could do it with ContentPlaceHolder like this:

Master Page:

    <Link rel="stylesheet" type="text/css" href="common.css" />
    <ContentPlaceHolder ID="Head" />

Child Page (Layout = Master Page):

<asp:Content ContentPlaceHolderID="Head">
     <Link rel="stylesheet" type="text/css" href="specific.css" />


How to do it in ASP.NET MVC?

Solution :

In your Layout page put something like this:

@RenderSection("AdditionalStyles", required: false)

Then in your child pages where you want to use it, you can do:

@section AdditionalStyles

    CSS Howto..

    Not floating on same line, how to fix css

    How to make animation smooth

    How to put space between figure in image?

    How to set an Ionic list item height with a background image

    how to set word break in table th or td, when column and table-layout auto using CSS

    How to define the color of characters in OL/LI lists via CSS, WITHOUT using any image bullets or any span tag?

    How to center a 3 column Css Div Site?

    How to place a scroll down button in the middle of split screen window?

    How to do taxonomy based css styling using drupal template.php?

    How to apply “!important” from CSS via jQuery? [duplicate]

    How do you force a website to be in landscape mode when viewed on a mobile device?

    How to specify discrete mapper style in cytoscapejs?

    how to use css align control one row

    How to downsize a larger image while showing only one portion of it in CSS (or adding JS to the mix if necessary)?

    How to make div blocks not floating using CSS?

    How to change elevation property of paper-card?

    How to put two divs on the same line with CSS in simple_form in rails?

    How can I style a JavaFX SplitMenuButton in CSS

    how to change element css class runtime using javascript

    How to make image override parent width and stretch to browser width?

    How to show borders of th elements with gradient fills in IE9?

    How to make a list of “background-image” CSS using WebDriver with Java

    How to fix the heading in html table using css

    How to use scss with css modules / postcss inside components

    How can I have a blue background on a hover even with css? [closed]

    How to remove strange border from css-animated clip-path?

    How to prevent fixed button from overlapping footer area and stop the button on top of where the footer is located

    How to get a button to fill the full width of the footer in Mobile View?

    How to align image within nested div<> with spaces in div names

    How to achieve Expand collapse Side Nav with icon using jquery and boostrap css