gpt4 book ai didi

c# - StyleBundle 被渲染为 ScriptBundle

转载 作者:太空狗 更新时间:2023-10-29 22:30:55 27 4
gpt4 key购买 nike

我的 CSS StyleBundle正在呈现 <script>标签而不是 <link>标签。

这让我摸不着头脑。我一直在寻找我的错字,但一切看起来都很好。

这是我的 BundleConfig.cs

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

bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));

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

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));

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


bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/all.css"));

BundleTable.EnableOptimizations = false;
}

这是我的 _Layout.cshtml 中的头部:

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/Content/themes/base/css")
@RenderSection("head", required: false)
</head>

HTML 是这样呈现的:

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page - My ASP.NET Application</title>
<link href="/Content/bootstrap.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>

<script src="/Scripts/modernizr-2.6.2.js"></script>

<script src="/Content/themes/base/all.css"></script>


</head>

布局有点偏离,所以看起来好像是向上的,但我看不到是什么。为什么它不在 <link> 中呈现 css 文件?标签?

最佳答案

在您的布局中,这一行:

@Scripts.Render("~/Content/themes/base/css")

应该是:

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

关于c# - StyleBundle 被渲染为 ScriptBundle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26791719/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com