2

I've just faced an interestring issue. So, what I have:

  1. ASP.NET MVC app;
  2. AngularJS app inside this app.

Well, I have a layout page:

@using System.Web.Optimization


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>LinkShortener</title>
    @Styles.Render("~/bundles/css/")
    @Scripts.Render("~/bundles/app/libs/")
    @Scripts.Render("~/bundles/app/webapp/")
</head>
<body ng-app="app"></body>

Next, there is my Bundle.Config:

public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.IgnoreList.Clear();

            bundles.Add(new StyleBundle("~/bundles/css/").Include
                (
                    "~/Content/Css/Bootstrap/*.css"
                ));

            bundles.Add(new ScriptBundle("~/bundles/app/libs/")
                .Include("~/App/Libraries/jQuery/jquery-1.9.1.js")
                .Include("~/App/Libraries/Bootstrap/bootstrap.js")
                .Include("~/App/Libraries/Core/angular.js")
                .Include("~/App/Libraries/Core/*.js"));

            bundles.Add(new ScriptBundle("~/bundles/app/webapp/")
                .Include("~/App/App.js")
                .Include("~/App/Resources/*Module.js").Include("~/App/Resources/*.js")
                .Include("~/App/Controllers/LinkShortenModule.js").Include("~/App/Controllers/*Controller.js"));

        }

When I open my page in Google Chrome, I see something like this:

script loading loop, the image goes here

It seems any script is beging loaded with the some parameter and then again and again and again... It it the first time I see this problem. The page is locked by this loop and finally dies.

Is there anyone who could guess what the magic is going on?

Thanks in advance.

  • Try to remove this line .Include("~/App/Libraries/Core/angular.js") – Drag13 Jun 09 '16 at 19:42
  • You have `"~/App/Libraries/Core/angular.js"` and `"~/App/Libraries/Core/*.js"`. Those are duplicates. So it will load angular.js twice. I'm also guessing `"~/App/Resources/*.js"` has more angular scripts in it. `"~/App/Resources/*.js"` and `"~/App/Resources/*Module.js"` will pick up duplicates too. – DerekMT12 Jun 09 '16 at 19:46
  • @Vitalii, it solves the issue. But what's the trick? – Iwillbeagod Jun 09 '16 at 19:47
  • DerekMT12 says right. You just have duplicates :) Have a nice day :) – Drag13 Jun 09 '16 at 19:48
  • The number at the end is a cache-busting value so the browser always picks up the latest version when the bundle changes. – DerekMT12 Jun 09 '16 at 19:52
  • @DerekMT12, just updated my bundles to load every script manually (by name), it works fine, but this script crushes all down : `//.Include("~/App/Libraries/Core/angular-resource.js")` – Iwillbeagod Jun 09 '16 at 20:02

1 Answers1

0

Did you add @RenderSection("scripts", required: false) at end of them?

Archil Labadze
  • 4,049
  • 4
  • 25
  • 42