Thursday 20 December 2012

ASP.NET web optimization framework with MVC 3 & ASP.NET 4.0 web form

Facing problem in integrating web optimization framework with MVC 3. So here in this post we will see how we can integrate asp.net web optimization framework with MVC 3 and ASP.NET 4.0 web form application.

Web optimization framework was introduced with MVC 4 and it is included in default MVC 4 template. But we can use it with MVC 3 and ASP.NET 4.0 web form application as well. This is because web optimization framework is built on top of framework 4.0. So here are the steps to use web optimization framework with ASP.NET 4.0 application.

    Create new ASP.NET 4.0 web form or MVC 3 application
    Add web optimization package by issuing following command in Visual studio package manager console

    Now add following code in global.asax.cs

1    using System.Web.Optimization;
2   
3    protected void Application_Start()
4    {
5        Bundle commonBundle = new ScriptBundle("~/bundle/common")
6            .Include("~/scripts/common.js");
7        BundleTable.Bundles.Add(commonBundle);
8    }

Now build and browse ~/bundle/common and we can see minified version of JavaScript. So this is how we can see default bundle in action with ASP.NET 4.0 and MVC 3 application. You can refer my following post on advanced concept in web optimization framework.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.