System.Web.Optimization
has Been Installedbundle has been configured as below
using System.Web.Optimization;
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/Content/themes/base/js").Include("~/Scripts/Site.js"));
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include("~/Content/Site.css"));
}
}
add this to Layout.cshtml
@System.Web.Optimization.Scripts.Render("~/Content/themes/base/js")
@System.Web.Optimization.Styles.Render("~/Content/themes/base/css")
css minified succesfully but return 404 error for js file ?
Make sure that your virtual path for your bundle Content/themes/base/js
does not relate to a real path. Generally we use ~/bundles
in our virtual path for this reason.
Example
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/base/js").Include("~/Scripts/Site.js"));
bundles.Add(new StyleBundle("~/bundles/base/css").Include("~/Content/Site.css"));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With