Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it better to use HttpContext.Current.IsDebuggingEnabled or #if DEBUG?

Tags:

.net

debugging

I have a code that should run only in debug mode.

Is it better to use HttpContext.Current.IsDebuggingEnabled or "#if DEBUG ... #endif"?

Thanks,

like image 720
The Light Avatar asked Aug 17 '26 23:08

The Light


1 Answers

Those are 2 completely different things!

HttpContext.Current.IsDebuggingEnabled

is related to the current web.config setting

debug=true

where

#if DEBUG ... #endif

is related to the project configuration debug/release setting at build time

Be carefull!

like image 182
George Mavritsakis Avatar answered Aug 20 '26 14:08

George Mavritsakis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!