Usage of BundleConfig.cs file with sample an example in MVC

Follow below steps:


To add Bundle config file, first you need to add the Microsoft.AspNet.Web.Optimization nuget package to your web project:

Install-Package Microsoft.AspNet.Web.Optimization


Then under the App_Start folder create a new cs file called BundleConfig.cs.

Add below code in Bundleconfig file;

namespace BundleConfigEx
public class BundleConfig
public static void RegisterBundles(BundleCollection bundles)
bundles.Add(new ScriptBundle(“~/bundles/sciptsJS”).Include(“~/Scripts/jquery-{version}.js”));
BundleTable.EnableOptimizations = true;


bundles.Add(new ScriptBundle(“~/bundles/sciptsJS”).Include(“~/Scripts/jquery-{version}.js”));

we will add number of bundles(Based on Our requirement) like above line of code. 


For this we will register our bundles in Global.asax.cs file like below;



Now we can call this bundle in our _layout file (or) View(Index.cshtml) like below


Leave a Reply

Your email address will not be published. Required fields are marked *