Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can check debug mode in MVC cshtml page

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"
like image 922
alettin Avatar asked Sep 24 '17 15:09

alettin


People also ask

How can I tell if debugging is enabled in asp net?

In the Web. config file, locate the compilation element. Debugging is enabled when the debug attribute in the compilation element is set to true. Change the debug attribute to false to disable debugging for that application.

How do I debug a .razor page?

To debug, you need to find out what's happening to the value of key objects and variables such as weekday . Add output expressions by inserting @weekday as shown in the two places indicated by comments in the code. These output expressions will display the values of the variable at that point in the code execution.


1 Answers

Check these:

HttpContext.IsDebuggingEnabled

or

HttpContext.Current.IsDebuggingEnabled

Reference: IsDebuggingEnabled

like image 151
Alan Avatar answered Oct 08 '22 09:10

Alan