7

How I can check debug mode in MVC cshtml page? this code not working in cshtml page.

@{
bool isRelease = false;
#if DEBUG
isRelease = false;
#else
isRelease = true;
#endif
} @{ if(isRelease) { < p > result1 < /p > } else { < p > result2 < /p >} }

application display "result 2" but it must display "result 1"
alettin
  • 123
  • 1
  • 13

1 Answers1

8

Check these:

HttpContext.IsDebuggingEnabled

or

HttpContext.Current.IsDebuggingEnabled

Reference: IsDebuggingEnabled

Alan
  • 98
  • 1
  • 8