brinch
brinch

Reputation: 2614

How to reference js and css in MVC?

I would like to include my own custom js and css files in my MVC5 project. Should they be referenced in _Layout.cshtml like:

<script src=...></script>

or should they rather be referenced in BundleConfig.cs?

Upvotes: 2

Views: 1252

Answers (1)

Ufuk Hacıoğulları
Ufuk Hacıoğulları

Reputation: 38468

Including them in BundleConfig.cs gives you the bundling and minification features built in ASP.NET MVC. Referencing them in the layout does not have any advantages, you won't be able to reduce the request count or size. Use bundling if you are working on ASP.NET MVC 4 or higher.

Upvotes: 1

Related Questions