I have an ASP.Net MVC project and I want to implement bundling, but everything I can find on the internet directs me to open BundleConfig.cs
in App_Start
– however this file does not exist in my project. I have only three files in that folder: FilterConfig
, RouteConfig
and WebApiConfig
.
Bundle config wasn't generated when I created the solution (IIRC it was a blank ASP.NET MVC project at the beginning).
It seems like this should be really easy to do, but I just plain cannot figure it out.
P.S. Just to clarify to those not reading closely, this is for a MVC4/.Net 4.5 app created from scratch. The solution is marked below.
Best Answer
BundleConfig
is nothing more than bundle configuration moved to separate file. It used to be part of app startup code (filters, bundles, routes used to be configured in one class)To add this file, first you need to add the
Microsoft.AspNet.Web.Optimization
nuget package to your web project:Then under the App_Start folder create a new cs file called
BundleConfig.cs
. Here is what I have in my mine (ASP.NET MVC 5, but it should work with MVC 4):Then modify your Global.asax and add a call to
RegisterBundles()
inApplication_Start()
:A closely related question: How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app