- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
首先,我请大家耐心等待,因为我对 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"));
}
}
}
这就是我在 _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>
根据 Google Chrome 提供的开发者工具,它现在根本没有引用任何内容:
我真的不知道该怎么办。我注意到该 bundle 引用了我的解决方案资源管理器未显示的某些内容,例如没有/css 文件夹。我一直在搞乱它,没有任何结果或引用。
如果您好奇,这是我现在的解决方案资源管理器(我想它显示了您可能感兴趣的部分):
您知道为什么会发生这种情况吗?
最佳答案
您需要在应用程序启动时使用 System.Web.Optimization
程序集中的 BundleConfig.RegisterBundles(BundleTable.Bundles);
向应用程序注册 bundle 。
可以将其放置在 global.asax
文件中的 Application_Start()
方法中。
捆绑配置是一种配置要组合和缩小的文件的方法,默认情况下,当使用发布构建配置构建应用程序时会发生这种情况。因此,配置中传递的 URL 并不指向解决方案中的文件,而是提供在运行时捆绑和缩小的文件的端点。
一个好的起点是 bundling and minification article在 asp.net 网站上。
关于c# - BundleConfig.cs 没有引用任何内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26050914/
如何将以下 BundleConfig.cs 转换为 BundleConfig.json?我正在将 .NET 4.6.2 项目迁移到 NET ASP Core 2。收到以下错误,并尝试进行研究。还试图阅
我的包有问题。文件 .min 未按照 this link 上的报告生成. 我必须为它创建一个测试。这该怎么做? [TestInitialize] public void Setup() { B
我正在我的 ASP MVC 4 站点上使用以下 BundleCollection 项(第一次使用 MVC 4)。我正在尝试加载 jQuery 和 Backbone.js,但根据 Chrome 的控制台
首先,我请大家耐心等待,因为我对 ASP 和 C# 总体来说还是个新手,而且我可能没有像我希望的那样形成大多数概念。 我在使用 BundleConfig.cs 时遇到一些问题。显然它尝试引用的每个模块
我遇到的问题是,如果我对 CSS 或 javascript 文件进行更改,然后将其推送到生产环境,则客户端浏览器不会接受该更改,除非它们执行 ctrl+F5 刷新。我在一个拥有数千名用户的学校系统中工
我最近将 jquery.dataTables nuget 包添加到我的项目中,并且我想在 BundleConfig 中捆绑必要的文件。由于这个包安装在 Scripts 文件夹中的“DataTables
我使用bundleconfig.cs 类向我的应用程序添加一些 jQuery 脚本文件。 bundles.Add(new ScriptBundle("~/bundles/jquery").Includ
我已经阅读了几篇文章,并在互联网上到处寻找,试图找出为什么即使在本地运行时我的 BundleConfig 也无法正常工作。我已经指定了脚本和 css: bundles.Add(new S
我在 MVC4 中使用 c#,我的 CSS 文件有一个奇怪的问题。一切都在本地主机上完美运行。我在 CSS 文件中所做的更改正在起作用。当我将元素发布到托管服务器时出现问题,其中由 BundleCon
我在服务器的 IIS 7 中发布我的 MVC 网站。当我检查页面源代码时,我发现它没有像在我的笔记本电脑中那样正确呈现。 发布到IIS服务器后的页面源码如下: Index - abc System
我正在使用 Tom DuPonts MvcBundler,遵循他的指南:http://www.tomdupont.net/2012/03/configuring-bundles-in-mvc-4.ht
我正在尝试将 BundleConfig.cs 添加到我的 Mvc 项目中。我还添加到 Global.asax BundleConfig.RegisterBundles(BundleTable.Bund
我有一个 ASP.Net MVC 项目,我想实现捆绑,但我在互联网上找到的所有内容都指示我在 App_Start 中打开 BundleConfig.cs -但是这个文件在我的项目中不存在。我在该文件夹
public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/b
我创建了一个新的 ASP.NET 4.5.1 Web 表单项目。 我之前在 MVC 4 中使用过捆绑和缩小。 为什么根目录中有一个bundle.config文件,而App_Start中有一个Bundl
public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/b
我的 BundleConfig.cs 文件如下所示 (CSS): bundles.Add(new StyleBundle("~/Content/css").Include(
我有一个 ASP.Net MVC 项目,我想实现捆绑,但我在互联网上找到的所有内容都指示我在 App_Start 中打开 BundleConfig.cs -但是这个文件在我的项目中不存在。我在该文件夹
我正在努力尝试让 bundle 在 Core 2.0 网络应用程序中工作。我的 bundleconfig.json 文件中有以下内容: [ { "outputFileName": "www
如果我直接引用_layouts页面中的font-awesome.css。它会起作用 但是我在BundleConfig.cs中使用了。图标未显示。 bundles.Add(new StyleBund
我是一名优秀的程序员,十分优秀!