How can I determine what ‘mode’ my site is running under?
In this specific case, I have code in the code-behind pages that should act one way in ‘release’ mode – that is someone navigating there with a browser, and another way if I’m in debug mode coming from VS2008. (These are things like identifying which SQL connect string to use, whether or not to display certain error or warning messages, etc)
VS2008 is configured to go through IIS for a variety of reasons (Cassini is not an option).
Searching all through the help I can’t find anything but there HAS to be a way to identify how the website was started.
Thanks in advance.
I’m not sure what you mean. If you want to know if the application is currently being debugged, you can check the
System.Diagnostics.Debugger.IsAttachedproperty. If you want to know if the application is compiled in debug mode, then you can do this:Also, you can use ConditionalAttribute:
I strongly suggest reconsidering that though – in my experience, having different release and debug behaviour is an excellent way to introduce bugs to your production code.