为什么ResolveBundleUrl不适合自定义文件夹的工作? (MVC测试版4) [英] Why does ResolveBundleUrl not work for custom folders? (MVC Beta 4)

查看:94
本文介绍了为什么ResolveBundleUrl不适合自定义文件夹的工作? (MVC测试版4)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个全新的ASP.NET MVC 4 Beta版的Web应用程序,我重新安排我的文件夹,以匹配罗布科纳的的 VidPub.Web例如

From a brand-new ASP.NET MVC 4 Beta Web Application, I'm re-arranging my folders to match Rob Conery's VidPub.Web example

具体而言,这意味着,对于内容的最后的目录结构看起来像这样

Specifically, this means that the final directory structure for content looks like this


VidPub.Web
 |
 ---Public
    |
    |---Images
          |--- *.png 
    |---javascripts
          |--- *.js 
    |---stylesheets
         |----themes
              |---base  
                  |--- images
                  |--- *.css
        |----site.css

然而,当我更改 _Layout.cshtml

<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl(
           "~/Content/css")" 
           rel="stylesheet" 
           type="text/css" />

<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl(
           "~/Content/themes/base/css")" 
           rel="stylesheet" 
           type="text/css" />

<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl(
             "~/Scripts/js")"></script>

<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl(
           "~/Public/stylesheets/css")"
           rel="stylesheet" 
           type="text/css" />

<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl(
           "~/Public/stylesheets/themes/base/css")" 
           rel="stylesheet" 
           type="text/css" />

<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl(
           "~/Public/javascripts/js")"></script>

我结束了绝对没有在生成的HTML。

I end up with absolutely nothing in the resulting HTML.

<link rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" />
<script></script>

为什么没有拿起文件在新位置?

Why isn't it picking up the files in their new locations?

推荐答案

的Application_Start >使用 BundleTable.Bundles.EnableDefaultBundles(); 而不是 BundleTable.Bundles.RegisterTemplateBundles()的;

如果你看一下源 RegisterTemplateBundles 你可以看到,它实际上只寻找(并添加)具体JS和CSS文件。 EnableDefaultBundles ,另一方面确实pretty大致相同,当你添加自己捆绑为。

If you look at the source for RegisterTemplateBundles you can see that it actually only looks for (and adds) specific js and css files. EnableDefaultBundleson the other hand does pretty much the same as when you add you own bundles.

这篇关于为什么ResolveBundleUrl不适合自定义文件夹的工作? (MVC测试版4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆