My project structure looks like this:
- src
— class library 1
— class library 2
— web project - bin
— debug
— release
The default output directory for an MVC4 web project is .\Bin\ (i.e. within the web project’s directory), but I change it to something like ..\bin\debug\ or ..\bin\release\ to fit my above project structure. It compiles fine and the binaries go to the correct places.
But when I run the project it complains that Could not load type Myproject.MvcApplication, whereas if I don’t make the above changes then it works.
How do I control the location for the binaries? I want the output directory to be completely separate from the source directories – it’s easier to deploy and more secure because I don’t have a mixture of source and binaries in one place.
Short answer, you can’t. It has nothing to do with Visual Studio or even .NET, it’s an IIS restriction.
The reason is that IIS expects the bin directory to be directly under the web site folder location. This is a security mechanism that you cannot bypass. It’s purpose is to prevent a compromised web site from “escaping” from the bounds of the root directly of the site.
Why would you even WANT to do this?