ClientDependency in umbraco doesn't include my bundles

天涯浪子 提交于 2021-01-28 19:34:32

问题


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:

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 ?


回答1:


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


来源:https://stackoverflow.com/questions/39658502/clientdependency-in-umbraco-doesnt-include-my-bundles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!