【问题标题】:Bundling not working when deployed to azure asp mvc 4部署到 azure asp mvc 4 时捆绑不起作用
【发布时间】:2016-08-25 23:46:53
【问题描述】:

我有 css 文件和 js 文件,本地链接按预期呈现在头部,但在 azure 上根本没有呈现链接,为什么?

我查看了各种线程,大多数似乎都指向将包名称命名为与文件路径相同的问题,两者都是不同的。其他人说<compilation debug="true" targetFramework="4.5" />应该是 <compilation debug="false" targetFramework="4.5" /> 和其他人说要试试BundleTable.EnableOptimizations = true; 在 Bundle.config 中。没有为我工作,有人可以指出我正确的方向

我的包是

bundles.Add(new StyleBundle("~/assets/styles").Include(
                    "~/assets/plugins/bootstrap/css/bootstrap.min.css",
                    "etc...",
                    "~/assets/css/theme.css"));

        bundles.Add(new ScriptBundle("~/assets/scripts").Include(
                    "~/assets/js/filter.js",
                    "etc...",
                    "~/assets/js/ContactForm.js"));

我的文件夹结构是

assets/css
assets/js

在我的 _Layout.cshtml 中它们被称为

@Styles.Render("~/assets/styles")
@Scripts.Render("~/assets/scripts") 

【问题讨论】:

    标签: c# asp.net-mvc azure


    【解决方案1】:

    这可能是因为 assets 文件夹已经存在。您是否尝试过仅使用~/styles~/scripts

    您所做的假设是因为assets/styles 文件夹不存在,所以将创建一个虚拟路径。该问题更可能与 Azure 发现目录 assets 并将其中的所有内容视为实际资源有关,跳过了创建虚拟路径的点。如果我是你,我不会费心去尝试让它发挥作用,充其量你会得到你想要的,但实际上,最坏的情况是,你会在一件没有商业意义且没有实际意义的事情上浪费时间对用户体验的价值...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-23
      • 1970-01-01
      • 1970-01-01
      • 2019-04-09
      • 2016-06-23
      • 2014-12-28
      • 1970-01-01
      相关资源
      最近更新 更多