2016-06-09 78 views
2

我剛剛面對一個interestring問題。所以,我有:爲什麼ASP.NET MVC應用程序無限加載腳本?

  1. ASP.NET MVC應用程序;
  2. AngularJS應用程序內的這個應用程序。

嗯,我有一個頁面佈局:

@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> 

接下來是我的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")); 

     } 

當我在谷歌瀏覽器打開我的網頁,我看到類似此:

script loading loop, the image goes here

看起來任何腳本都裝載了一些參數,然後一次又一次地加載... 這是我第一次看到這個問題。該頁面被此循環鎖定並最終死亡。

有沒有人可以猜出魔法是怎麼回事?

在此先感謝。

+0

嘗試刪除此行 .INCLUDE( 「〜/應用/庫/核心/ angular.js」) – Vitalii

+0

你' 「〜/應用/庫/核心/ angular.js」'和'「〜/應用程序/庫/核心/ *。JS「'。那些是重複的。所以它會加載angular.js兩次。我也猜測'「〜/ App/Resources/*。js」'裏面有更多的角色腳本。 '「〜/ App/Resources/*。js」'和'「〜/ App/Resources/* Module.js」'也會重複。 – DerekMT12

+0

@Vitalii,它解決了這個問題。但是有什麼竅門? – Iwillbeagod

回答

0

你在結尾添加了@RenderSection("scripts", required: false)嗎?

相關問題