Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 568
Joel Peltonen Avatar asked May 03 '13 11:05

Joel Peltonen


People also ask

How do I debug my ASP.NET projects running under IIS?

To start debugging, select IIS Express (<Browser name>) or Local IIS (<Browser name>) in the toolbar, select Start Debugging from the Debug menu, or press F5. The debugger pauses at the breakpoints. If the debugger can't hit the breakpoints, see Troubleshoot debugging.

What is debug mode in a website?

What is Online Debugging? Online debugging is a feature that allows developers or testers to test and debug websites online directly through browsers in real-world conditions. Developers get instant access to DevTools, allowing them to inspect specific components for the desired device-browser combinations.

How do I run a .NET in debug mode?

NET Core Launch (console). Other ways to start the program in debugging mode are by pressing F5 or choosing Run > Start Debugging from the menu. Select the Terminal tab to see the "What is your name?" prompt that the program displays before waiting for a response.


2 Answers

HttpContext.IsDebuggingEnabled

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

like image 180
Britton Avatar answered Sep 21 '22 17:09

Britton


In some cases, you may need HttpContext.Current.IsDebuggingEnabled (sort of obvious, but nonetheless)

like image 32
Vasiliy Avatar answered Sep 20 '22 17:09

Vasiliy