asp.net-mvcumbracoumbraco7client-dependency

ClientDependency in umbraco doesn't include my bundles


Here is where I call the BundleManager:

public class MyUmbracoApplication : UmbracoApplication
{ 
    protected override void OnApplicationStarted(object sender, System.EventArgs e)
    {
        //register custom routes
        RouteConfig.RegisterRoutes(RouteTable.Routes);

        CreateBundles();

        base.OnApplicationStarted(sender, e);
    }

    public static void CreateBundles()
    {
        BundleManager.CreateCssBundle("css",
            new CssFile("~/css/rte.css"));

        BundleManager.CreateJsBundle("js",
            new JavascriptFile("/assets/js/custom.js"));
    }
}

Here is where I call the bundles (bottom of the page of my Master.cshtml) :

 <div class="test">
        @{
            Html.RequiresJsBundle("js");
            Html.RequiresCssBundle("css");
         }
    </div>

Here is what I get:

enter image description here

The content of my clientdependency temp xmp file:

<?xml version="1.0" encoding="utf-8" standalone="yes"?><map />

I gave full access to Everyone (on local), the files have the same securities than the folder (assets/css, assets/js)

I have the standard ClientDependency.config file.

What did I do wrong ?


Solution

  • I finally figured out. Html.RequiresJsBundle("customjs1") just makes the current page dependent on the bundle, you'd still need to use Html.RenderJsHere to output the script tag.

    source: https://github.com/Shazwazza/ClientDependency/issues/1

    Here is how I rendered the bundles:

    Html.RequiresJsBundle("customjs1"); // at the top of the page, inside @{}
    
    @Html.RenderJsHere() // where the js needs to be rendered - at the bottom of the page for me