捆绑和放大器;微小不应用CSS和放大器; JS使用Asp.net 4.0 C# [英] Bundling & minification not applying css & js using Asp.net 4.0 C#

查看:237
本文介绍了捆绑和放大器;微小不应用CSS和放大器; JS使用Asp.net 4.0 C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来这个概念,这是我与实现(捆绑销售和放大器;微小)优化概念,第一个项目

I am new to this concept, this is my first project implementing the optimization concept with (Bundling & minification)

只是我试图用简单的JS和放大器测试; CSS

Just i am trying to test with simple js & css

Test.aspx文件

<html>
<%@ import namespace="System.Web.Optimization" %>
<html>
<head runat="server">
    <%: Scripts.Render("~/bundles/js") %>
    <%: Styles.Render("~/bundles/css") %>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <button id="tests">
            testing</button>
    </div>
    </form>
</body>
</html>

Global.asax中看起来像这样

protected void Application_Start(object sender, EventArgs e)
{
    RegisterBundles(BundleTable.Bundles);
}

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/js").Include(
     "~/script/jquery-1.8.2.min.js",
     "~/script/s.js"));

    bundles.Add(new StyleBundle("~/bundles/css").Include(
     "~/css/master.css"));

    BundleTable.EnableOptimizations = true;
}



项目结构看起来像这样


 



浏览器中查看


browser View

该文件被捆绑,但在CSS中我有一些风格网页渲染,它没有出现在此,

the file are Bundling, but in Css i have some style to render in the webpage, it nothing appearing on this,

样品像jQuery的文件还

有关生根粉这个职位的详细信息,请检查该.. <一个href=\"http://orums.asp.net/p/1962886/5610113.aspx?Re%20Bundling%20minification%20not%20applying%20css%20js%20using%20Asp%20net%204%200%20C%20\"相对=nofollow>点击此处

for more info abt this post, please check this..Click here

您可以指导我实现这个...

can you guide me to achieve this...

推荐答案

您绑定工作正常,问题是你的CSS捆绑时不工作。

Your bundling is working, problem is you css are not working when bundled.

更改样式表包名称是:

bundles.Add(new StyleBundle("~/css/allcss").Include("~/css/master.css"));

这应该解决您的问题。

P.S。如果你保持你的CSS文件在多个文件夹,然后为每个文件夹包。您可以使用 IncludeFolder 方法,让您的工作更轻松。

P.S. if you keep your css files in multiple folders, then create a bundle for each folder. You can use the IncludeFolder method to make your job easier.

这篇关于捆绑和放大器;微小不应用CSS和放大器; JS使用Asp.net 4.0 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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