I have a new ASP.NET MVC5 project. I don't want to use Microsoft bundling and minification so I removed the nuget package and the dependencies that I also don't want.
I ensured there was nothing left in the config and I cleared out \Temp\Temporary ASP.NET Files\
I am using VS2013 / IIExpress and there is nothing that references System.Web.Optimization in the aspnet.config or the applicationhost.config
...the solution builds fine but when I run it throws:
Compiler Error Message: CS0234: The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Something somewhere is trying to pull in the dll, but it's not my code. Seems very odd!
Line 26: using System.Web.Optimization;
Surely it's not reference by MVC5 itself. Anyone seen this before?
I just found it in the Views folder when I did a search for 'namespaces', no idea how I missed it. I didn't even know there was a config file in the Views folder.
The System. Web. Optimization namespace includes classes that support Content Delivery Networks (CDN) and the process of optimizing JavaScript and cascading style sheet (CSS) files in a website to reduce file size and improve page performance.
You can uninstall Microsoft ASP.NET MVC 4 Runtime from your computer by using the Add/Remove Program feature in the Window's Control Panel.
ASP.NET Optimization introduces a way to bundle and optimize CSS and JavaScript files.
You can uninstall Microsoft ASP.NET MVC 2 from your computer by using the Add/Remove Program feature in the Window's Control Panel.
I found
<add namespace="System.Web.Optimization" />
in the Web.config file under the Views folder. It doesn't get removed with the package.
In Visual Studio 2012, There was a problem after creating a new Area. In Web.Config of that Area, There was a statement (line) that Visual Studio Compiler wants to use Microsoft.AspNet.Web.Optimization! And when you run the application and you want to see some of views in that Area, You get an error because of that statement (line).
Solution (1)
Delete that statement (line) Microsoft.AspNet.Web.Optimization in Web.Config of Areas (in Visual Studio 2012)
Solution (2)
You can install the Web.Optimization for your application with NUGET:
INSTALL-PACKAGE Microsoft.AspNet.Web.Optimization
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With