c# - Azure 不加载捆绑包
问题描述
我在 Visual Studio 中使用“Web API”模板启动了一个项目。然而,该项目开始增长,我需要建立一个网站。在本地运行时,所有功能都正确,但是我在 Azure 中发布站点后,无法识别 CSS 样式。
这是我的引导目录:
这是我的 Bundle 类的代码:
public static class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/Content/Scripts/jquery").Include(
"~/Content/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/Content/Scripts/modernizr").Include(
"~/Content/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/Content/Scripts/bootstrap").Include(
"~/Content/Scripts/bootstrap.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/css/bootstrap.css",
"~/Content/css/site.css"));
}
}
主要布局如下:
<!DOCTYPE html>
<html>
<head>
...
@Styles.Render("~/Content/css")
@Scripts.Render("~/Content/Scripts/modernizr")
</head>
<body>
<div class="container-fluid">
...
@RenderBody()
...
</div>
@Scripts.Render("~/Content/Scripts/jquery")
@Scripts.Render("~/Content/Scripts/bootstrap")
<script src="~/Content/CustomScripts/Global.js"></script>
@RenderSection("scripts", required: false)
</body>
</html>
以下类似的问题(link1 y link2)提到有必要更改 Bundle 存档名称,但是当我发布到 Azure 时它不起作用;但是,如前所述,它在本地可以正常工作。
解决方案
推荐阅读
- php - 从外部访问 php 文件时出现 404 错误
- javascript - 导入很多东西是否被认为是特定于 React 的东西?
- pandas - 按数据类型选择 pandas 列
- c++ - 如何创建 operator*(double) 以在左侧和右侧进行乘法运算?
- spring - Spring注解:org.springframework.beans.factory.BeanCreationException
- machine-learning - 正常和朴素贝叶斯 - 复制数据,改进分类 [Weka]
- python - 如何从 Python 中的列表中计算项目?
- c++ - 串行端口 - 以 uint8 发送数据
- mysql - 尝试使用 golang 插入表格时出现恐慌
- z3 - Z3 悬挂式通用量化