Fixing 'System.Web.Optimization.BundleCollection' does not contain a definition for 'EnableDefaultBundles' error

asp.net-mvc, asp.net-mvc-4

Solution

Make sure you get the latest `Microsoft Asp.Net Web Optimization Framework` via the NuGet.

Verify that you have `BundleConfig.cs` placed in the `App_Start` folder and also verify that the `BundleConfig.cs` has its Namespace set to the application root Namespace like: `namespace MeApp`

In the Global.asax use `BundleConfig.RegisterBundles(BundleTable.Bundles);`

protected void Application_Start()
{
    ...
    BundleConfig.RegisterBundles(BundleTable.Bundles);
    ...
}

Problem

This error began to appear after update to the latest version of Optimization of System.Web.Optimization. 'System.Web.Optimization.BundleCollection' does not contain a definition for 'EnableDefaultBundles' This also applies for `BundleTable.Bundles.RegisterTemplateBundles();`

Original source