BundleConfig错误403 - 风格和JavaScript

时间:2016-01-04 02:06:28

标签: asp.net-mvc bundling-and-minification

它,所以现在我不能让我的风格显示在页面上。它只是在我的HTML中提出了这些东西。

我试过看这里 MVC bundeling : Err 403

<link href="/Content/?v=QJxA7R8Re3uqMX1yrXXxo93tvLZiLQJPzVSY80tOo9s1" rel="stylesheet">
<link href="/Content/skins/?v=cvum26wsOdSFqp48CXFJ39rlGKOSzsCvOJZuuLeX4901" rel="stylesheet">

_Layout.cshtml

@Styles.Render("~/Content/")
@Styles.Render("~/Content/skins/")

BundleConfig.cs

public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new StyleBundle("~/Content/skins/").Include(
                  "~/Content/skins/default.css"));

        bundles.Add(new StyleBundle("~/Content/").Include(
                  "~/Content/theme.css",
                  "~/Content/theme-*"));
    }

它给了我一个错误。 enter image description here

这是我的文件夹。

enter image description here

EIDT(更新)

BundleConfig.cs

public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new StyleBundle("~/bundle/skins").Include(
                  "~/Content/skins/default.css"));

        bundles.Add(new StyleBundle("~/bundle/Content")
            .Include("~/Content/theme.css")
            .Include("~/Content/theme-blog.css")
            .Include("~/Content/theme-animate.css")
            .Include("~/Content/theme-elements.css"));

        bundles.Add(new StyleBundle("~/bundle/Scripts")
            .Include("~/Scripts/bootstrap/bootstrap.min.css")
            .Include("~/Scripts/owlcarousel/owl.carousel.min.css")
            .Include("~/Scripts/owlcarousel/owl.theme.default.min.css")
            .Include("~/Scripts/magnific-popup/magnific-popup.css"));
    }

Layout.cshtml

@Styles.Render("~/bundle/Content")
@Styles.Render("~/bundle/skins")
@Styles.Render("~/bundle/Scripts")

1 个答案:

答案 0 :(得分:2)

您的问题是,您为捆绑包提供的名称与解决方案中的现有文件夹相同。

修复方法是更改​​捆绑包的名称,以免它们与现有文件夹冲突。

例如,代替~/Content/skins使用~/bundle/skins

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new StyleBundle("~/bundle/skins").Include(
              "~/Content/skins/default.css"));
}

然后:

@Styles.Render("~/bundle/skins")