ViewBag、样式、样式未在 ASP.NET MVC 5 中的layout.cs html 中呈现

问题描述 投票:0回答:1

我将所有

Styles
Scripts
都捆绑在我的
BundleConfig.cs
文件中。但是在引用我的
_layout.cshtml
文件时,我收到此错误:

名称 Styles 在当前上下文中不存在,名称 Scripts 在当前上下文中不存在。

这是捆绑包的代码和

_layout.cshtml

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/jquery")
                        .Include("~/Scripts/jquery-{version}.js",
                                 "~/Scripts/bootstrap.min.js",
                                 "~/Scripts/jquery.dataTables.min.js",
                                 "~/Scripts/jquery.alerts.js",
                                 "~/Scripts/jquery.autocomplete.multiselect",
                                 "~/Scripts/jquery-confirm.min.js",
                                 "~/Scripts/table2excel.js",
                                 "~/Scripts/dataTables.buttons.min.js",
                                 "~/Scripts/buttons.flash.min.js",
                                 "~/Scripts/jszip.min.js",
                                 "~/Scripts/pdfmake.min.js",
                                 "~/Scripts/vfs_fonts.js",
                                 "~/Scripts/buttons.html5.min.js",
                                 "~/Scripts/buttons.print.min.js"));
}


<title>@ViewBag.Title - Fiber Inventory Portal</title> // here is the error
    @Styles.Render("~/Content/css") // here is the error
    @Scripts.Render("~/bundles/modernizr") // here is the error
    @Scripts.Render("~/bundles/jquery") // here is the error
    @Scripts.Render("~/bundles/jqueryui") // here is the error
    @Scripts.Render("~/bundles/AppLog")

即使在编译、刷新和清理代码之后,它仍然不起作用

html razor asp.net-mvc-5
1个回答
0
投票

我认为这可能是对所请求文件的引用错误。我建议您仔细检查目录和文件。也许这就是你的问题所在。我会继续调查,但目前我没有其他想法。

© www.soinside.com 2019 - 2024. All rights reserved.