ResolveBundleUrl没有解决所有的文件吗? [英] ResolveBundleUrl not resolving all files?
问题描述
我是新来的MVC所以以为我会开始一个新的项目,并尝试一些在MVC4的新功能。我在我的内容两个CSS文件
目录, normalise_mini
和的site.css
。当我用下面的code:
I am new to MVC so thought I would start a new project and try out some of the new features in MVC4. I have two css files in my Content
directory, normalise_mini
and site.css
. When I use the following code:
<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/css")" rel="stylesheet" type="text/css" />
只需要我的的site.css
文件不是我的规范化文件。我在我的应用程序启动以下内容:
It only takes my site.css
file not my normalisation file. I have the following in my app start:
protected void Application_Start()
{
// Remove all other view engines except razor:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
BundleTable.Bundles.RegisterTemplateBundles();
BundleTable.Bundles.EnableDefaultBundles();
}
我是否需要为每个CSS文件捆绑(如这的人做)?或者,它应该只是找到所有自动将CSS文件(这是我所期望的是默认的行为)。我开始这个项目的基础上的Razor视图引擎空网站(这实际上是不为空都:/),这可能是值得一提的
Do I need to create a bundle for each css file (as this person is doing)? Or should it just find all the css files automatically (which I would expect to be the default behaviour). It might be worth noting that I started this project as a Empty Website based on Razor view engine (which actually wasn't empty at all :/)
在此先感谢
更新
据发布的链接,我需要注释掉注册模板包线。例如:
According to the link posted, I need to comment out the line that registers the template bundles. Eg:
protected void Application_Start()
{
// Remove all other view engines except razor:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
//BundleTable.Bundles.RegisterTemplateBundles(); // This is not needed
BundleTable.Bundles.EnableDefaultBundles();
}
这现在工作。我的想法是,这两个行应该没有任何问题并存。我想这是由设计,但它是坏的设计?
This now works. My thoughts are that the two lines should co-exist without any problems. I guess it's by design, but is it bad design?
推荐答案
有人已回答了这个问题:
Someone else has already answered this question:
的http://forums.asp.net/t/1776599.aspx/1?MVC+4+0+Bundling+Minification+not+working+
更新:
有人有pssed担心,链接可能不足以回答这个问题前$ P $。虽然我仍然认为,人谁访问这个页面应该链接线,简单的答案是从的Application_Start(删除BundleTable.Bundles.RegisterTemplateBundles()线)和BundleTable.Bundles.EnableDefaultBundles取代它()
Someone has expressed concern that a link may not be enough to answer the question. Although I still believe that someone who visits this page should read the linked thread, the short answer is to remove the BundleTable.Bundles.RegisterTemplateBundles() line from Application_Start() and replace it with BundleTable.Bundles.EnableDefaultBundles()
这篇关于ResolveBundleUrl没有解决所有的文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!