asp.net-optimization

VS2012 - Web Forms - Bundling Confusion

不想你离开。 提交于 2019-11-28 15:53:00
I created a new ASP.NET Web Forms Project through Visual Studio 2012. Unfortunately, the default Site.Master file is very confusing. (I am posting these questions together because they are very related and reference the same code quite a bit.) First off, I already understand the purpose of bundling and minification, so no need to discuss that. However I do not understand what is going with the way the scripts are being included in the default master page. Question 1: Why is a bundle called "~/bundles/WebFormsJs" being created in the BundleConfig.cs file, and yet in the master page, each of

How do I get System.Web.Optimization bundles to work with custom folders in an IIS virtual directory?

落花浮王杯 提交于 2019-11-28 13:24:08
I have an asp.net mvc4. I have modules that are deployed as subdirectories within this application using IIS Virtual Directories and I need to reference files in these modules. These module dlls are registering bundles. But the bundles are not generating anything into the html page. From this post, is-it-possible-to-unit-test-bundleconfig-in-mvc4 , I see that internally the bundles are using Server.MapPath. So it seems like it should work. I hooked BundleTable.MapPathMethod and even called Server.MapPath myself which does correctly resolve to the right physical directory. But it still won't

Ordering of Files within a bundle - What are the known libraries?

▼魔方 西西 提交于 2019-11-28 12:04:36
In Bundling and Minification, I've known that the bundler will move around certain known file types -- so that things like jQuery will be moved to the front. By default, when files are bundled by ASP.NET they are sorted alphabetically first, just like they are shown in Solution Explorer. Then they are automatically shifted around so that known libraries and their custom extensions such as jQuery, MooTools and Dojo are loaded before anything else. -source But after reading this recent question: ASP.NET MVC - Bundle Config order , which shows how a file is getting moved by the bundler even when

How to disable Javascript/CSS minification in ASP.NET MVC 4 Beta

烈酒焚心 提交于 2019-11-28 08:23:57
I am just trying out ASP.NET MVC 4 but I can't figure out how to disable Javascript/CSS minification feature. Especially for development environment this will help greatly on debugging. I would imagine it would be a switch in web.config but since ASP.NET MVC 4 is still in beta stage at the moment there's really not much information out there. Would appreciate if someone can help or point to the right blog posts etc. In Global.asax.cs #if DEBUG foreach (var bundle in BundleTable.Bundles) { bundle.Transform = new NoTransform(); } #endif Another option would be to create an HTML Helper that you

How to upload bundled and minified files to Windows Azure CDN

允我心安 提交于 2019-11-28 03:42:01
I'm using the ASP.NET MVC 4 bundling and minifying features in the Microsoft.AspNet.Web.Optimization namespace (e.g. @Styles.Render("~/content/static/css") ). I'd like to use it in combination with a Windows Azure CDN. I looked into writing a custom BundleTransform but the content is not optimized there yet. I also looked into parsing and uploading the optimized stream on runtime but that feels like a hack to me and I don't really like it: @StylesCdn.Render(Url.AbsoluteContent( Styles.Url("~/content/static/css").ToString() )); public static IHtmlString Render(string absolutePath) { // get the

MVC4 partial view javascript bundling Issue

自作多情 提交于 2019-11-28 01:53:10
I am working on a project ASP.net 4, MVC4(RC) using visual studio 11. I am trying to render an MVC4 Razor view that renders a partial view. I have some javascript required for my partial view. On my partial view when I include my javascript inside the scripts section as follows it does not seem to load. @section Scripts { <script type="text/javascript"> $(function () { alert("test"); }); </script> } If I remove the scripts section it fails as the jquery libraries (which are bundled and rendered on my _Layout.cshtml page) have not yet loaded when the document ready code runs. <script type="text

MVC4 bundling CSS failed Unexpected token, found '@import'

你说的曾经没有我的故事 提交于 2019-11-27 19:35:29
I'm trying to use bundling to combine & minify some CSS files. In my Global.aspx.cs Application_Start I have the following: var jsBundle = new Bundle("~/JSBundle", new JsMinify()); jsBundle.AddDirectory("~/Scripts/", "*.js", false); jsBundle.AddFile("~/Scripts/KendoUI/jquery.min.js"); jsBundle.AddFile("~/Scripts/KendoUI/kendo.web.min.js"); BundleTable.Bundles.Add(jsBundle); var cssBundle = new Bundle("~/CSSBundle", new CssMinify()); cssBundle.AddDirectory("~/Content/", "*.css", false); cssBundle.AddDirectory("~/Content/themes/base/", "*.css", false); cssBundle.AddFile("~/Styles/KendoUI/kendo

Adding the new ASP.NET Web Optimization framework to MVC4 projects after manually upgrading them

扶醉桌前 提交于 2019-11-27 12:28:24
问题 After manually upgrading an ASP.NET MVC project to MVC4 using these instructions, how do you then set up the new CSS and JavaScript asset bundling and minimization features of the ASP.NET Web Optimization Framework in MVC4? The default templates have this all set up, but how do you do it by hand? 回答1: Right click References then Manage NuGet Packages and add “Microsoft.AspNet.Web.Optimization” (or type Install-Package Microsoft.AspNet.Web.Optimization into the NuGet console). In your Web

ASP.NET Bundling - Bundle not updating after included file has changed (returns 304 not modified)

倖福魔咒の 提交于 2019-11-27 11:24:54
I am trying out ASP.NET Bundling with ASP.NET MVC 4 application. The situation is that I want to make a CDN style service, which has JS and CSS files to which you can address from other sites with this type address: http://www.mycdn.com/scripts/plugin/js , which bundles and minifies all included .js files. My bundle config for one file looks like this: bundles.Add(new ScriptBundle("~/Scripts/plugin/pluginjs").Include("~/Scripts/plugin/jquery.plugin.js")); However, when I do this, the bundles are not getting updated even after I change the original js files. I keep on getting 304 Not Modified,

ASP.NET MVC4 Bundling with Twitter Bootstrap

风格不统一 提交于 2019-11-27 11:07:18
I'm trying to use the new bundling feature in MVC 4 with Twitter bootstrap and it seems to me like the paths to the glyphicons png-files int the css get's messed up in some way. Heres my code: bundles.Add(new StyleBundle("~/bundles/publiccss").Include( "~/Static/Css/bootstrap/bootstrap.css", "~/Static/Css/bootstrap/bootstrap-padding-top.css", "~/Static/Css/bootstrap/bootstrap-responsive.css", "~/Static/Css/bootstrap/docs.css")); bundles.Add(new ScriptBundle("~/bundles/publicjs").Include( "~/Static/Js/jquery-1.7.2.js", "~/Static/Js/bootstrap/bootstrap.js", "~/Static/Js/cookie/jquery.cookie.js")