I\'m working on an MVC 4 project started in Visual Studio 2010. Right now I\'m working on a machine with Visual Studio 2012 as I don\'t have access to the machine I was original
This is a long shot but here it goes anyway, right click on the project --> Property Pages and make sure System.Web.Optimization entry exists. If not, copy the System.Web.Optimization.dll to your bin folder or import it as a reference.
Edit: mvc projects don't have the "Property pages" menu option.
One other thing you can try is create a new mvc4 basic project, go to the bin folder of the solution and copy the System.Web.Optimization.dll to the bin folder of your other project that is giving you the error. If you can't find the dll then try updating the nuget packages.
I know it's confusing, but you will need to Install-Package Microsoft.AspNet.Web.Optimization
What worked for me in a specific scenario (I downloaded a MVC project from source control and received that error), was to open a new MVC project on the same solution. Afterwards I could delete the new project I've created and it still works (on VS2012).
I battled this for an hour and none of the above suggestions worked. In the end only the following worked (for some obtuse reason) :
Uninstall-Package Microsoft.AspNet.Web.Optimization <problem project name>
Install-Package Microsoft.AspNet.Web.Optimization <problem project name>
Microsoft.AspNet.Web.Optimization
. If you want a particular version (say v1.1.1), use Install-Package Microsoft.AspNet.Web.Optimization <problem project name> -Version 1.1.1
<problem project name>
parameter or nuget will operate at the Solution-level, possibly trampling sibling projects.Go to tools >> Library Package Manager >> Manage Nuget Packages >> install Microsoft ASP.NET web optimisation framework
Reinstalling system.web.optimizaiton using Nuget package manager solved this issue for me..