profile

Bundling and Minification Support in the new ASP .NET

ASP.NET MVC, ASP .NET MVC 4, Bundling, Minification

With the introduction of ASP .NET MVC 4.5 and the upgrade that many sites are going to this (to include the Orchard CMS framework) comes a multitude of amazing features. With NuGet we got package management that is similar to NPM for Node and the RubyGem packaging system for Ruby, and with Bundling we get built in bundle support that has been offered through providers like dotLess and Squish-It. So the question is, how do you get bundling from ASP .NET MVC 4?

Three steps:

1.       Create a method that registers your bundles

2.       Call this method from the App Start method of your Global.asax

3.       Introduce your bundle directory onto your page in this fashion:

                a.       <script type=”text/javascript” src=”~/Your/Bundle/Config/Setting”></script>

 

Step 1

Create a method that registers your bundles

Step 2

Call this method from the App start method of your Global. Asax

Step 2.5

Turn off debugging from Web.Config

Step 3

Add script tag to your page

(I won't paste an image of a script tag...just know you have to reference the bundle that you put as the first parameter passed into the ScriptBundle class listed in step 1)

1 Comment

  • Hugh Jackman said

    Hi!

    Bundling and minification are two techniques you can use in ASP.NET 4.5 to improve request load time. Bundling and minification improves load time by reducing the number of requests to the server and reducing the size of requested assets (such as CSS and JavaScript.)
    So thanks for sharing this important information through this article. There are few other links that have described for manage "Bundling and minification".

    http://www.mindstick.com/Articles/2d3da74a-94da-45fe-b361-97263cd725f2/?Bundling%20and%20Minification%20in%20ASP%20NET%20MVC%204

    http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification

Add a Comment