Search code examples
c#asp.netweb-config

A preferred way to check if asp.net web application is in debug mode during runtime?


During compile time I can do a check like

#if DEBUG
    Log("something");
#endif

But what would be the preferred to check if debug="false" is set in Web.config during runtime?


Solution

  • HttpContext.IsDebuggingEnabled

    https://learn.microsoft.com/en-us/dotnet/api/system.web.httpcontext.isdebuggingenabled