How to add js and css files in ASP.net Core?


Tags: c#,jquery,css,asp.net-mvc,asp.net-core-mvc

Problem :

I've been assigned to migrate an application from MVC into ASP.net Core, I'm new to ASP.net Core. In MVC we have BundleConfig.cs and in there we add references to our css and js files, how does it work in ASP.net Core? Let's say that I created a test.js and a MyStyle.css class, which is the best way to add references to it in every view? Should I place the .js and .css files inside wwwroot/js and wwwroot/css?



Solution :

I added the references inside the _Layout view, inside the <environment> tags:

 <environment names="Development">
 <link rel="stylesheet" href="~/css/MyCss.css" />
    </environment>

If anyone knows a better way I would welcome it


    CSS Howto..

    How do I align this icon while having the input take 100% width?

    Given an image button with borders how to stretch/repeat middle part in CSS for variable length content?

    How can I Resize & Enlarge an Image (like sprite icons) via CSS 3?

    Finding correct CSS sheet when Chrome Inspector shows (index) [closed]

    HTML emails in 2013: How to control spacing between elements like paragraphs and images?

    How do I change the z-index of a div when the user mouses over it?

    How to align tags withina div

    If you remove float: left they are centred, in combination with setting text-align: center with their parent div. That is, their immediate (first) parent div; give this an id....
    Read more

    How to add a background color to HTML option?

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

    How to center multiple div elements within a parent div?

    How can I use CSS to center text in DIV

    how to 3D rotate a 'a' tag?

    How to fit two divs side by side horizontally?

    How to make CSS menu bar activated only after my mouse cursor is at the menu.

    Why don’t my box borders surround the floats inside them without this CSS fix? (And how does the fix work?)

    how to align css content string

    How can I add a gradient overlay to an image that is set in a style attribute in css?

    ASP.NET - How to include CSS only if it isn't alrealy included?

    How to find resources(CSS , JS Etc) that are blocking in Chrome

    How to make entire div change color on hover using css?

    How to set dynamic value in css? [closed]

    How to center text with CSS?

    How to display a background image with a:hover

    How to format text in input box with css

    how to text zoom effect in css

    How do I remove white space due to position relative of CSS?

    How to move the POV of an image when using overflow: hidden?

    How do you set the background color for a variable height page?

    How to create a dropdown with lu and li tags like this

    jQuery UI sortable: how to leave css values of changed items untouched?