Azure发布版本未显示捆绑包

时间:2015-03-20 16:42:47

标签: azure asp.net-mvc-5 bundle

当我将调试版本发布到Azure上时......我的所有样式文件都可以访问。

当我将我的发布版本发布到Azure上时......我的风格都无法访问。

You do not have permission to view this directory or page.

在我的代码中,我有这样的包:

        bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/Packages/Bootstrap/src/bootstrap.css",
                  "~/Content/CSS/site.css",
                  "~/Content/CSS/bootstrap-theme-conflicts.css" ) );

在我的剃刀视图中,我有这个:

@Styles.Render( "~/Content/css" )

我的内容文件夹结构是:

enter image description here

已发布申请中的最终网址是:

azurewebsites.net/Content/css/?v=i2nuaUMdmGVopZ-yRx75EKwl3vXByH5xgX4-uk0R9oE1

如果我直接去文件...即:

azurewebsites.net/Content/CSS/Site.css

他们没事。

有用的资源:

Bootstrap icons are loaded locally but not when online

3 个答案:

答案 0 :(得分:3)

捆绑名称必须代表文件的真实目录+ 1级别...所以我添加了我的目录,然后在最后添加了word文件。单词文件然后成为文件名!

因此,对于我的例子,我不得不拆开我的捆绑包:

        bundles.Add(new StyleBundle("~/bundle/Packages/Bootstrap/src/files").Include(
                  "~/Content/Packages/Bootstrap/src/bootstrap.css"));

        bundles.Add(new StyleBundle("~/bundle/CSS/files").Include(
                  "~/Content/CSS/site.css",
                  "~/Content/CSS/bootstrap-theme-conflicts.css"));

然后在我的剃刀观点中,我将我改为:

@Styles.Render("~/Content/Packages/Bootstrap/src/files")
@Styles.Render("~/Content/CSS/files")

答案 1 :(得分:2)

我在Azure网站中部署代码时遇到了这个问题。当我从visualstudio.com部署构建时,它确实起作用,当我尝试从visual studio 2013发布构建时,它确实有用。主要问题是CSS Minification。我完全同意对这个问题的第一反应。但想到分享对我有用的解决方案,可能会帮助你修复它。

基本上当我们通过VSO进行部署时,它会通过在system.web.Optimization中踢出来为css,js生成缩小文件,但是当我们从VS 2013发布版本时,我们必须处理以下内容。 bundling-and-minification 1.确保文件夹结构和bundler命名约定应该不同。像这样的东西。

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

2。添加到bundleconfig定义的底部

public static void RegisterBundles(BundleCollection bundles)
{
  bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
             "~/Scripts/jquery-{version}.js"));

   // Code removed for clarity.
   BundleTable.EnableOptimizations = true;
}

3。确保在web.config中添加debug false(当你启动本地debuging VS2013时会给你一个弹出窗口,告诉你需要确保在部署到prod之前把它放回去。这本身解释得很多。

<system.web>
  <compilation debug="true" />
  <!-- Lines removed for clarity. -->
</system.web>

有关详情,请访问why-is-my-css-bundling-not-working-with-a-bin-deployed-mvc4-app

答案 2 :(得分:0)

在下面的代码中

  

function call and instead saw an expression no-unused-expressions Line 220: 'jQuery' is not defined no-undef Line 233:

您需要添加“捆绑包”代替内容,以便您的代码如下所示:

  

inp_str = u'\xd7\nRecord has been added successfully, record id: 92' print inp_str.encode('ascii',errors='ignore').strip('\n') Results : 'Record has been added successfully, record id: 92'

相关问题