First of all add the references of System.Web.Optimization.dll and WebGrease.dll to your MVC3 and Asp.Net 4.0 projects as shown below. You can download the dll by using download link.
Now create the bundle for your css and js files with in the Global.asax file as shown below.
Here, I have created the bundle of all required css and js files. You can also add your own css and js files with complete path using Include method.
Adding Bundles to Layout Page in MVC3:
Now you can add the above created style and script bundles to the Layout page or where you want to use as shown below:
Adding Bundles to Master Page in Asp.Net 4.0:
Now you can add the above created style and script bundles to the Master page or where you want to use as shown below:
In Asp.Net 4.0 you also required to add System.Web.Optimization namespace and assembly Microsoft.AspNet.Web.Optimization.WebForms reference to the web.config file of your Asp.Net 4.0 project as shown below:
You need not to do any changes in web.config file of your MVC3 project.
Enabling Bundling and Minification in debug mode
Bundling and minification doesn’t work in debug mode. So to enable this features you need to add below line of code with in Application_Start event of Global.asax.
How it works..
Now run your application and you will see that all the css and js files are converted to single css and js file as shown below:
Hope it helps!