AlexGH AlexGH - 27 days ago 6
jQuery Question

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

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
?

Answer

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