In Razor compiler directives do not work, cause Razor Views are not compiled.
So this would not work:
@{ #if DEBUG}
@{#else}
@{#endif}
But you can trick that thing into submission, thanks to this StackOverflow topic
A better, more generic solution is to use an extension method, so all views have access to it:
public static bool IsReleaseBuild()
{
#if DEBUG
return false;
#else
return true;
#endif
}
You can then use it like follows in any view (razor syntax):
@if(IsReleaseBuild())