2015-08-29 84 views
0

腳本和樣式在頁面未呈現,腳本和樣式不是渲染

MVC

HTML源代碼ASP.NET

<html> 
    <head> 
     <meta charset="utf-8" /> 
     <meta name="viewport" content="width=device-width" /> 
     <title>@ViewBag.Title</title> 
     @Styles.Render("~/Content/css")   
    </head> 

    <body > 
    @Scripts.Render("~/Scripts/js") 
    @RenderSection("Scripts", false) 
    </body> 
</html> 

這是我所有的腳本和樣式BundleConfig文件c#,我做的都是我知道的

public class BundleConfig 
     { 
    // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 
      public static void RegisterBundles(BundleCollection bundles) 
      { 
       BundleTable.EnableOptimizations = true; 

       bundles.Add(new ScriptBundle("~/Scripts/js").Include(
        "~/Scripts/jquery-{version}.js", 
        "~/Scripts/angular.js", 
        "~/Scripts/ang/app.js", 
        "~/Scripts/jquery.unobtrusive-ajax.min.js", 
        "~/Scripts/jquery-ui-1.11.2.js", 
        "~/Scripts/jquery.bpopup.min.js", 
        "~/Scripts/jquery-ui.min.js",      
        "~/Scripts/jquery.validate.min.js", 
        "~/Scripts/jquery.validate.unobtrusive.min.js", 
        "~/Scripts/ui.dropdownchecklist-1.4-min.js", 
        "~/Scripts/sweetalert.min.js", 
        "~/Scripts/jquery.lettering.js", 
        "~/Scripts/ang/app.js", 
        "~/Scripts/js/JavaScript1.js", 
        "~/Scripts/js/JavaScript2.js"        
        )); 
       bundles.Add(new StyleBundle("~/Content/css").Include(
        "~/Content/jquery-ui.css", 
        "~/Content/css/StyleSheet.css", 
        "~/Content/StyleSheet1.css"  , 
        "~/Content/jquery-ui.css", 
        "~/Content/ui.dropdownchecklist.standalone.css", 
        "~/Content/ui.dropdownchecklist.themeroller.css", 
        "~/Content/sweetalert.css", 
        "~/Content/animate.css"  
        )); 

       // Set EnableOptimizations to false for debugging. For more information, 
       // visit http://go.microsoft.com/fwlink/?LinkId=301862   
      } 

ASP.NET MVC的HTML源代碼的結果可以看到有NONE SCRIPTS ANS STYLES

<html> 
    <head> 
     <meta charset="utf-8" /> 
     <meta name="viewport" content="width=device-width" /> 
     <title>Index</title> 
     <link href="/Content/css" rel="stylesheet"/> 
    </head> 
<body > 
    <script src="/Scripts/js"></script>  
</body> 
</html> 
+0

會發生什麼事,當你設置EnableOptimizations假? – drneel

+0

沒有什麼相同的 – Link

回答

0

添加BundleConfig.RegisterBundles(BundleTable.Bundles);到Global.asax中

0

您可能加載jquery.ui.css兩次......

"~/Content/jquery-ui.css", 
"~/Content/css/StyleSheet.css", 
"~/Content/StyleSheet1.css"  , 
"~/Content/jquery-ui.css" 

見第一和最後一個行...