我对ASP.NET没有任何想法,但我尝试了一些博客并添加了用于缩小Microsoft.AspNet.Web.Optimization和WebGrease dll文件的dll文件。 我正在尝试缩小CSS文件,但是当我调试并看到我无法看到它缩小但它唯一的捆绑
我的班级文件
using System.Web.Optimization;
using Umbraco.Core;
namespace MySolution.helpers
{
public class CustomEventHandler : IApplicationEventHandler
{
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{ }
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{ }
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
RegisterStyles(BundleTable.Bundles);
RegisterJavascript(BundleTable.Bundles);
}
private static void RegisterStyles(BundleCollection bundles)
{
bundles.Add(new StyleBundle("~/bundle/styles.css").Include(
"~/css/carousel.css" , "~/css/menu.css" , "~/css/blog.css" , "~/css/general.css"
) );
bundles.Add(new StyleBundle("~/bundle/ultradata-styles.css").Include(
"~/css/ultradata-styles.css"
) );
BundleTable.EnableOptimizations = true;
}
private static void RegisterJavascript(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundle/javascript.js").Include(
"~/scripts/*.js"
)
);
}
}
}
web config debug已经为假
<compilation defaultLanguage="c#" debug="false" batch="false" targetFramework="4.6.2" numRecompilesBeforeAppRestart="50">
任何人都可以帮助我,我缺少什么
和umbraco中的CMS我这样打电话
@using System.Web.Optimization
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
}
<!doctype html>
<html>
<head>
<title>@Umbraco.Field("pageName")</title>
<meta charset="utf-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, shrink-to-fit=no, initial-scale=1">
<meta name="description" content="@Umbraco.Field("metaDescription")">
<meta name="keywords" content="@Umbraco.Field("metaKeywords")">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="~/css/socialiconstyle.css" />
<link rel="stylesheet" href="~/css/bootstap/css/bootstrap3.css" />
<link rel="stylesheet" type="text/css" href="/css/iconfont.css">
@Styles.Render("~/bundle/styles.css" , "~/bundle/ultradata-styles.css")
答案 0 :(得分:0)
您是否在web.config文件中将/bundle
路径添加到Umbraco的保留路径中:
<add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/bundle" />