The company I work for has 2 servers, 1 release and 1 test/debug server. I want to restrict the release server that only code that is compiled as release (not having the DEBUG constant defined) can be run.
Is this possible and if so, how can I achive this? Can I set this in IIS or in the web.config?
There is no difference in the compiled assemblies when you compile with one flag versus another. The names "Debug" and "Release" are purely conventional. The setting I assume you are concerned about is whether the code is optimized or not. That too is not detectable.
Instead, as @HABO suggested, the answer would be to define a flag, present on developer's machines, which makes debug code acceptable. You could use something as simple as the following: