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 can I create inline CSS in a WordPress PHP file without referencing to an external CSS file?

    How to overlap elements inside of a ng-repeat list - position: absolute?

    how to tag multiple elements? [closed]

    How can you make an absolute positioning in css to adjust after the text modification?

    How to get the sticky footer to work?

    css - how to determine why a particular css rule is being overwritten

    How to style a GWT CaptionPanel?

    How can i use ng-class variable from controller?

    How to implement css classes in form using laravel collective 5.2 . *

    How to achieve two multi-step forms, one form on each side using CSS transformation

    How to get drop down menu sub lists to line up vertically

    How to use ViewContext?

    How do I iterate through array and set classes individually?

    How to set a dynamic CSS value with JavaScript

    how can I reload a “CSS background-image” each time I hover on it?

    How to overlay “transformed” element?

    TUMBLR CSS - How to move the caption on the permalink page to the right of the image

    Rails 4 -how to write a view that displays instances in alternating format

    How to break a table with CSS diagonally or vertically?

    How to add focus on label css style

    How to combine components in HTML header

    How to optimize my css/html webpage? [closed]

    CSS How to Make Image Display outside of div

    in a css three column setup using the float:left how do I horizontally centre an image inside each column

    How to achieve vertical alignmernt of text paragraphs between Bootstrap columns

    How to override the width property in css [closed]

    CSS: How to get an animated gif background-image on top of a div

    How make a page fit on any screen with any orientation [closed]

    How to have div horizontally scroll when resized.

    How to dim an image keeping transparency untouched with CSS or JS?