How to add custom css files to asp.net mvc?

asp.net-mvc, asp.net-mvc-4, vb.net

Solution

Try this :

bundles.Add(New StyleBundle("~/AllStyles").IncludeDirectory("~/images","img.css")_
                         .IncludeDirectory("~/content","con.css")_
                         .Include("~/styles.css"))

In your view Page:

<%: Styles.Render("~/AllStyles") %>

or

bundles.Add(New StyleBundle("~/bundles/img").Include("~/images/img.css"))
bundles.Add(New StyleBundle("~/bundles/content").Include("~/content/con.css"))
bundles.Add(New StyleBundle("~/bundles/style").Include("~/styles.css"))

In your view Page:

<%: Styles.Render("~/bundles/img","~/bundles/content","~/bundles/style") %>

And remind that you must add in the Global.asax.vb file this `BundleConfig.RegisterBundles(BundleTable.Bundles);`

Problem

How to add css files in asp.net mvc4 project. I have 3 css files like this ``` images/img.css content/con.css styles.css ``` i added in bundleconfig.vb but its not working. ``` bundles.Add(New StyleBundle("~/Content/css").Include("~/images/img.css")) bundles.Add(New StyleBundle("~/Content/css").Include("~/content/con.css")) bundles.Add(New StyleBundle("~/Content/css").Include("~/styles.css")) ``` In view page ``` <%: Styles.Render("~/Content/css") %> <%: Scripts.Render("~/bundles/modernizr") %> ```

Original source