Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bundle and minification return 404

  1. Package System.Web.Optimizationhas Been Installed
  2. bundle 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"));
    
        }
    }
    
  3. 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 ?

like image 228
Moslem7026 Avatar asked Sep 09 '13 12:09

Moslem7026


1 Answers

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"));

}
like image 88
Colin Bacon Avatar answered Nov 11 '22 09:11

Colin Bacon