Recently we upgraded an MVC 3 application to MVC4 and wanted to take advantage of the new bundling and minification functionality for our css and js files. There are some great articles on the asp.net site about how to use all of these new features:
http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification
Initially I tested it out on a brand new MVC 4 project I created in VS2012. It worked exactly as advertised, so I was anxious to get it working in one of our actual production web applications. However, my first attempts at adding bundling to our application left me a little frustrated.
When I tried to add the example code for using BundleConfig and BundleTable to my Global.asax, these classes could not be found. That seemed a little strange since this was a working MVC4 application. Why were the references available in the brand new application I had created (based on the MVC4 application template) and not in my upgraded MVC4 application?
After doing a little research I realized that the MVC4 template in VS had references to Nuget packages which included this functionality. So the new optimization framework was not part of the MVC bits, but rather an add-on package. This actually made a lot of sense because it allows it to easily be shared with other types of ASP.NET projects and to be deployed in isolation. I just wasn’t expecting this initially, so it took me a little time to figure out where to get the bits I needed to add this functionality to our application.
To add bundling and minification to an existing MVC application you need to add the following Nuget packages:
I would recommend grabbing the latest versions of these packages. Once you’ve done that then the rest should work as advertised. Enjoy!
This is a very nice article on “ASP.NET MVC4 BUNDLING AND MINIFICATION: WHERE DID SYSTEM.WEB.OPTIMIZATION GO?”. I have find out following article that help to add reference of “System.Web.Optimization” in our application. I think this is very helpful for developers like me.
http://mindstick.com/Articles/e9e9a790-9f3f-4b8b-ad5d-9fdcef53a05c/?Add%20reference%20of%20System.Web.Optimization%20in%20MVC%204
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.asp.net/mvc/tutorials/mvc-4/bundling-and-minification
http://www.mindstick.com/Articles/2d3da74a-94da-45fe-b361-97263cd725f2/?Bundling%20and%20Minification%20in%20ASP%20NET%20MVC%204