我想将 Bundle 添加到现有的 ASP.NET MVC 4 (.NET 4.5) 网站中,该网站使用:
- Umbraco 6.1.5
- Microsoft ASP.NET Web 优化框架 1.1.3 ( https://www.nuget.org/packages/microsoft.aspnet.web.optimization/ )
我尝试遵循这些指示:https ://gist.github.com/jkarsrud/5143239 ,并且在我开始使用捆绑路径之前,CSS 加载良好。
在页面加载时,它会插入样式参考:
<link href="/bundles/marketingcss" rel="stylesheet">
但是会发生 404 错误:
> GET http://localhost:20459/bundles/marketingcss 404 (Not Found)
这是我在代码中的内容:
网络配置
<add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/bundles" />
全球.asax
<%@ Application Codebehind="Global.asax.cs" Inherits="MapCom.Global" Language="C#" %>
全球.asax.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
using System.Web.Security;
using System.Web.SessionState;
using Umbraco.Web;
namespace MapCom
{
public class Global : UmbracoApplication
{
protected void Application_Start(object sender, EventArgs e)
{
base.OnApplicationStarted(sender, e);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
}
_Layout.cshtml
@Styles.Render("~/bundles/marketingcss");
BundleConfig.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
namespace MapCom
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
BundleTable.EnableOptimizations = true;
///
///Marketing Site CSS Bundle
///
bundles.Add(new StyleBundle("~/bundles/marketingcss")
.Include("~/plugins/bootstrap/css/bootstrap.min.css")
.Include("~/css/font-awesome.min.css")
.Include("~/plugins/parallax-slider/css/parallax-slider.css")
.Include("~/css/combinedStyles.min.css")
.Include("~/plugins/ladda-buttons/css/ladda.min.css")
.Include("~/plugins/ladda-buttons/css/custom-lada-btn.css"));
}
}
}
有任何想法吗?