【问题标题】:Bundle of Kendo UI is not working in IISKendo UI 捆绑包在 IIS 中不起作用
【发布时间】:2013-06-09 21:58:45
【问题描述】:

我正在使用 Kendo UI 在 ASP.NET MVC 4 中开发一个应用程序,整个应用程序通过运行 Visual Studio 2012 可以完美运行,但是当发布到 Kendo 的 IIS 捆绑包时不起作用,整个界面未配置。 下面是类代码 BundleConfig 和 Layout 调用:

BundleConfig.cs

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));

        bundles.Add(new ScriptBundle("~/bundles/kendo").Include(
                    "~/Scripts/kendo/2013.1.514/jquery.min.js",
                    "~/Scripts/kendo/2013.1.514/kendo.all.min.js",
                    "~/Scripts/kendo/2013.1.514/kendo.aspnetmvc.min.js",
                    "~/Scripts/kendo.modernizr.custom.js",
                    "~/Scripts/kendo/2013.1.514/cultures/kendo.culture.pt-BR.min.js",
                    "~/Scripts/kendo/2013.1.514/cultures/kendo.culture.es-ES.min.js"));

        bundles.Add(new ScriptBundle("~/bundles/noty").Include(
                    "~/Scripts/noty/jquery.noty.js",
                    "~/Scripts/noty/layouts/top.js",
                    "~/Scripts/noty/layouts/topLeft.js",
                    "~/Scripts/noty/layouts/topCenter.js",
                    "~/Scripts/noty/layouts/topRight.js",
                    "~/Scripts/noty/themes/default.js"));

        bundles.Add(new ScriptBundle("~/bundles/nicescroll").Include("~/Scripts/jquery.nicescroll.min.js"));

        bundles.Add(new ScriptBundle("~/bundles/fancy").Include(
                    "~/Scripts/fancy/jquery.fancybox.js",
                    "~/Scripts/fancy/jquery.facybox.pack.js"));

        bundles.Add(new StyleBundle("~/Content/site").Include("~/Content/Site.css","~/Content/ResetKendo.css"));

        bundles.Add(new StyleBundle("~/Content/pwb4").Include("~/Content/pwb4.css"));

        bundles.Add(new StyleBundle("~/Content/kendo").Include(
                    "~/Content/kendo/2013.1.514/kendo.common.min.css",
                    "~/Content/kendo/2013.1.514/kendo.blueopal.min.css",
                    "~/Content/kendo/2013.1.514/kendo.dataviz.min.css",
                    "~/Content/kendo/2013.1.514/kendo.dataviz.blueopal.min.css"));

        bundles.Add(new StyleBundle("~/Content/fancy").Include("~/Content/fancy/jquery.fancybox.css"));


        bundles.IgnoreList.Clear();
        AddDefaultIgnorePatterns(bundles.IgnoreList);
    }

    public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
    {
        if (ignoreList == null)
            throw new ArgumentNullException("ignoreList");
        ignoreList.Ignore("*.intellisense.js");
        ignoreList.Ignore("*-vsdoc.js");
        ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
    }
}

Layout.cshtml

<html>
<head>
    <title></title>
    <link href="~/assets/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="X-UA-Compatible" content="IE=10; IE=9; IE=8; IE=7; IE=EDGE" />

    @Styles.Render("~/Content/site")
    @Styles.Render("~/Content/pwb4")
    @Styles.Render("~/Content/kendo")
    @Scripts.Render("~/bundles/kendo")
    @Scripts.Render("~/bundles/noty")
    @Scripts.Render("~/bundles/nicescroll")
    @Scripts.Render("~/bundles/jqueryval")

</head>
<body>
</body>
</html>

有人有解决这个问题的建议吗?

【问题讨论】:

  • 我确定你已经完成了这里的剑道步骤,但以防万一:docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/…
  • 如果你使用你的浏览器开发工具,所有的包都会显示为加载。例如,使用 Chrome 会在 Sources -> Site Name -> bundles 下显示什么?此外,如果你将 jquery 拉到它自己的包中会发生什么(就像我之前评论中链接到的官方剑道步骤所做的那样)
  • 你能确定你没有运行调试模式吗?

标签: html asp.net-mvc-4 kendo-ui


【解决方案1】:

我设法通过将虚拟路径“~/Content/kendo”更改为“~/Content/kendoui”来解决问题。在我的项目中有一个物理路径“~/Content/kendo”,而虚拟路径与物理路径不匹配。

以下是更正后的代码:

        bundles.Add(new StyleBundle("~/Content/kendoui").Include(
                    "~/Content/kendo/2013.1.514/kendo.common.min.css",
                    "~/Content/kendo/2013.1.514/kendo.blueopal.min.css",
                    "~/Content/kendo/2013.1.514/kendo.dataviz.min.css",
                    "~/Content/kendo/2013.1.514/kendo.dataviz.blueopal.min.css"));

感谢G_P和Win的关注。

【讨论】:

【解决方案2】:

发现这个documentation对这件事解释得很好,

希望对你有帮助

【讨论】:

    【解决方案3】:

    更改版本号 (2016.1.112) 并试试这个:

    BundleConfig.cs

    bundles.Add(new StyleBundle("~/Content/kendo/2016.1.112/kendostyles").Include(
                          "~/Content/kendo/2016.1.112/kendo.common-bootstrap.min.css",
                          "~/Content/kendo/2016.1.112/kendo.mobile.all.min.css",
                          "~/Content/kendo/2016.1.112/kendo.dataviz.min.css",
                          "~/Content/kendo/2016.1.112/kendo.bootstrap.min.css",
                          "~/Content/kendo/2016.1.112/kendo.dataviz.bootstrap.min.css"));
    
    BundleTable.EnableOptimizations = true;
    

    _Layout.cshtml

    @Styles.Render("~/Content/kendo/2016.1.112/kendostyles")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-06
      • 2014-04-10
      • 1970-01-01
      • 1970-01-01
      • 2014-12-28
      • 1970-01-01
      • 2016-07-07
      • 2023-04-09
      相关资源
      最近更新 更多