MVC Script Wrong Order Bindings after debugging are set to false

UPDATE: after a while the package works fine, don't know what it was)

In my BundleConfig.cs I have these packages defined

public static void RegisterBundles(BundleCollection bundles) 
{
    bundles.Add(new ScriptBundle("~/bundles/vendor").Include(
        "~/Scripts/jquery-{version}.js",
        "~/Scripts/bootstrap.js",
        "~/Scripts/bootstrap-datetimepicker.js",
        "~/Scripts/es6-shim.js",
        "~/Scripts/toastr.js",
        "~/Scripts/angular.js",
        "~/Scripts/angular-route.js",
        "~/Scripts/highcharts.src.js",
        "~/Scripts/highcharts-ng.js",
        "~/Scripts/angular-block-ui.js",
        "~/Scripts/angular-translate.js"));

    bundles.Add(new ScriptBundle("~/bundles/app").Include(
        "~/Scripts/app/app.js",
        "~/Scripts/app/directives.js",
        "~/Scripts/app/translation.js",
        "~/Scripts/app/data.service.js",
        "~/Scripts/app/main.controller.js",
        "~/Scripts/app/parameters.controller.js",
        "~/Scripts/app/schedules.controller.js",
        "~/Scripts/app/settings.controller.js",
        "~/Scripts/app/subscriptions.controller.js"));
}

      

In my Index.cshtml file I have this sequence of adding these packages

@Scripts.Render("~/bundles/vendor")
@Scripts.Render("~/bundles/app")

      

If in web.config

<compilation debug="true" targetFramework="4.5">

I have the correct package sequence

enter image description here

If I change debug to false

<compilation debug="false" targetFramework="4.5">

the sequence is broken and the application does not work!

Why is this happening? How to fix?

enter image description here

+3


source to share


1 answer


It is not typical to use more than one Scripts.Render

glued on a page where you can combine scripts into one package. This may be required when you are working with partial / conditional scripts in certain views where we use RenderSection

to achieve our goal.

Your problem is coming from a reality that associates the alphabetical order for wildcard names. In your case, a pp is called before v .

My first solution , using one Scripts.Render

if possible.



The second solution would be to change the call location of the second Scripts.Render

, say, application scripts, for example by using them at the bottom of the page or using tags in meta

between (not after the vendor to avoid ordering).

If you want to make sure the scripts are in the correct order , don't use multiple Scripts.Render

. Instead, customize the order for a single package .

+1


source







All Articles