An alternative to my other answer, because I just noticed the mvc tag, whereas earlier I assumed that you were using WebForms.
Is the piece of code you provided in the view?
Because if this is the case, the DEBUG parameter for your project will not be respected when the view is created at runtime - it will only respect the debug flag in your web.config file.
See this answer for more information.
source
share