【问题标题】:Rendering a script bundle within webforms application issue在 webforms 应用程序问题中呈现脚本包
【发布时间】:2015-04-08 11:48:24
【问题描述】:

我有一个网络表单应用程序,在母版页中我有这个:

    <%: Styles.Render("~/bundles/CssBootstrap") %>  
   <%: Scripts.Render("~/bundles/Query") %>  
  <%: Scripts.Render("~/bundles/modernizr") %>  

BundleConfig.cs 文件中我有

 bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
            "~/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/bundles/Query").Include(
            "~/Scripts/WebForms/jquery-1.9.1.js",
            "~/Scripts/WebForms/jquery-1.9.1.intellisense.js",
            "~/Scripts/WebForms/bootstrap.js" 
            ));

        bundles.Add(new StyleBundle("~/bundles/CssBootstrap").Include(
           "~/Content/bootstrap.css"
           ,"~/Content/bootstrap.css-theme" 
           ));

当我运行应用程序时,我会在页面的源代码中得到这个:

 <link href="/bundles/CssBootstrap?v=czIWtJIp8NT-Vut_P5jm8e1wcrWStCXZx8WrJTcjZSA1" rel="stylesheet">
<script src="/bundles/Query?v="></script>
<script src="/bundles/modernizr?v=_crq2QUT7I_NAMAaEv7T-Hgr0jkqYYHmaNBKKo2em_Q1"></script>

第二个 ScriptBundle Query 没有像我想的那样工作。

  1. 这个错误的原因是什么?
  2. 我该如何解决?

【问题讨论】:

  • 试试BundleTable.EnableOptimizations = true; 看看有没有效果
  • 您是否删除了ScriptManager 中的Query 脚本引用?

标签: javascript c# asp.net webforms bundle


【解决方案1】:

尝试不带扩展名如下:

bundles.Add(new ScriptBundle("~/bundles/Query").Include(
            "~/Scripts/WebForms/jquery-1.9.1",
            "~/Scripts/WebForms/jquery-1.9.1.intellisense",
            "~/Scripts/WebForms/bootstrap" 
            ));

希望对你有帮助...

谢谢。

【讨论】:

    猜你喜欢
    • 2011-03-23
    • 2022-07-22
    • 1970-01-01
    • 2020-01-28
    • 2014-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多