asp.net-optimization

MVC4 - Bundling does not work when optimizations are set to true

徘徊边缘 提交于 2019-11-27 11:06:50
I wonder what I don't do correct here. I am using ASP.NET C# MVC4 and I want to take use of new css/js optimization feature. Here is my HTML part @Styles.Render("~/content/css") Here is my BunduleConfig.cs part bundles.Add(new StyleBundle("~/content/css").Include( "~/content/css/reset.css", "~/content/css/bla.css")); // BundleTable.EnableOptimizations = true; Output (works): <link href="/content/css/reset.css" rel="stylesheet"/> <link href="/content/css/bla.css" rel="stylesheet"/> However when I uncomment BundleTable.EnableOptimizations = true; html output looks like this <link href="/content

{version} wildcard in MVC4 Bundle

[亡魂溺海] 提交于 2019-11-27 10:58:37
In MVC 4 we have bundles. While defining the bundles we can use wildcards like * for all files in a folder. In the example below what does -{version} mean? public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js")); } Hao Kung The -{version} basically maps to a version regex , or to be precise: (\d+(?:\.\d+){1,3}) . Using * tends to grab too much, for example if you bundle jquery* , that will include jquery-ui as well which might mess up the ordering. But using jquery-{version}.js would let you

Why use @Scripts.Render(“~/bundles/jquery”)

北战南征 提交于 2019-11-27 10:04:30
How does @Scripts.Render("~/bundles/jquery") differ from just referencing the script from html like this <script src="~/bundles/jquery.js" type="text/javascript"></script> Are there any performance gains? Bundling is all about compressing several JavaScript or stylesheets files without any formatting (also referred as minified) into a single file for saving bandwith and number of requests to load a page. As example you could create your own bundle: bundles.Add(New ScriptBundle("~/bundles/mybundle").Include( "~/Resources/Core/Javascripts/jquery-1.7.1.min.js", "~/Resources/Core/Javascripts

MVC4 Less Bundle @import Directory

只谈情不闲聊 提交于 2019-11-27 09:40:21
问题 I'm trying to use MVC4 bundling to group some of my less files, but it looks like the import path I'm using is off. My directory structure is: static/ less/ mixins.less admin/ user.less In user.less, I'm attempting to import mixins.less using this: @import "../mixins.less"; This used to work for me before when using chirpy with dotless, but now I noticed ELMAH was getting mad at me, saying this: System.IO.FileNotFoundException: You are importing a file ending in .less that cannot be found.

VS2012 - Web Forms - Bundling Confusion

浪尽此生 提交于 2019-11-27 09:24:37
问题 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 "~

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

不羁岁月 提交于 2019-11-27 07:38:40
问题 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

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

若如初见. 提交于 2019-11-27 06:42:28
问题 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

How to force BundleCollection to flush cached script bundles in MVC4

拈花ヽ惹草 提交于 2019-11-27 06:21:51
... or how I learned to stop worrying and just write code against completely undocumented APIs from Microsoft . Is there any actual documentation of the official System.Web.Optimization release? 'cuz I sure can't find any, there's no XML docs, and all the blog posts refer to the RC API which is substantially different. Anyhoo.. I am writing some code to automatically resolve javascript dependencies and am creating bundles on the fly from those dependencies. Everything works great, except if you edit scripts or otherwise make changes that would affect a bundle without restarting the application

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

帅比萌擦擦* 提交于 2019-11-27 02:16:36
问题 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. 回答1: In Global.asax.cs #if DEBUG foreach (var bundle in BundleTable.Bundles)

MVC4 partial view javascript bundling Issue

人走茶凉 提交于 2019-11-26 22:04:28
问题 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