BundleConfig.cs没有引用任何东西?

kri*_*ieg 2 c# asp.net asp.net-mvc razor bundling-and-minification

对于初学者,我要求你们所有人都忍受我,因为我对ASP和C#总体上并不熟悉,而且我可能没有像我希望的那样塑造大多数概念.

我在BundleConfig.cs上遇到了一些问题.显然,它试图引用的每个模块都不起作用,或者找不到它?

这是我得到的BundleConfig:

using System.Web;
using System.Web.Optimization;

namespace WebApplication
{
    public class BundleConfig
    {
        // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
        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*"));

            // Use the development version of Modernizr to develop with and learn from. Then, when you're
            // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));

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

            bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                        "~/Content/themes/base/jquery.ui.core.css",
                        "~/Content/themes/base/jquery.ui.resizable.css",
                        "~/Content/themes/base/jquery.ui.selectable.css",
                        "~/Content/themes/base/jquery.ui.accordion.css",
                        "~/Content/themes/base/jquery.ui.autocomplete.css",
                        "~/Content/themes/base/jquery.ui.button.css",
                        "~/Content/themes/base/jquery.ui.dialog.css",
                        "~/Content/themes/base/jquery.ui.slider.css",
                        "~/Content/themes/base/jquery.ui.tabs.css",
                        "~/Content/themes/base/jquery.ui.datepicker.css",
                        "~/Content/themes/base/jquery.ui.progressbar.css",
                        "~/Content/themes/base/jquery.ui.theme.css"));
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这就是我在_Layouyt.cshtml中引用的内容

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
        <title>@ViewBag.Title</title>
        @Styles.Render("~/Content/css")
        @Styles.Render("~/Content/themes/base/css")
        @Styles.Render("~/Content/site.css")
        @Scripts.Render("~/bundles/modernizr")
        @Scripts.Render("~/bundles/jquery")
        @Scripts.Render("~/bundles/jqueryui")
        @Scripts.Render("~/Scripts/jquery.validate.min.js")
        @Styles.Render("~/Content/bootstrap.min.css")
        @Styles.Render("~/Content/layoutsheet.css")
    </head>
    <body>
    ....
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

根据谷歌浏览器提供的开发者工具,它现在正处于现状,它根本没有引用任何内容:

没有参考?

我真的不知道该怎么办.我注意到捆绑包引用了我的解决方案资源管理器未显示的某些内容,例如没有/ css文件夹.我一直在搞乱它,没有任何结果或参考.

如果你很好奇,这就是我现在的解决方案资源管理器(我想它会显示你可能感兴趣的部分):

Solution Explorer

你知道为什么会发生这种情况吗?

Rus*_*Cam 5

您需要注册与应用程序束某处应用开始使用BundleConfig.RegisterBundles(BundleTable.Bundles);来自System.Web.Optimization装配.

可以放置的一个地方是文件中的Application_Start()方法global.asax.

捆绑配置是一种配置文件以进行组合和缩小的方法,默认情况下,在使用发布版本配置构建应用程序时.因此,配置中传递的URL不指向解决方案中的文件,而是提供在运行时捆绑和缩小的文件的端点.

一个好的起点是asp.net网站上的捆绑和缩小文章.