8

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.

7
  • What's the exact error you're seeing? Commented Aug 3, 2014 at 8:29
  • Possibly in Web.Config file <system.web><pages><namespaces> section Commented Aug 3, 2014 at 8:46
  • Can you post the full stacktrace as well? Commented Aug 3, 2014 at 8:47
  • @stephen-muecke I have checked that several times. It's a pretty minimal config file. Commented Aug 3, 2014 at 8:53
  • 1
    Did you check both files (the one in the Views folder as well)? Commented Aug 3, 2014 at 8:57

2 Answers 2

21

I found

<add namespace="System.Web.Optimization" /> 

in the Web.config file under the Views folder. It doesn't get removed with the package.

Sign up to request clarification or add additional context in comments.

4 Comments

What exactly did you find in the Views folder?
I found another Web.config file, this had the <add namespace="System.Web.Optimization" />
Thanks man. I had the same issue. Didn't knew how missed it too :P
This, put a smile in my face.
3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.