I am drawing a blank here for something that should be simple...
I am trying to do something like:
<my:control runat="server" id="myid" Visible="<%= (is compilation debug mode?) %>" />
config file, locate the compilation element. Debugging is enabled when the debug attribute in the compilation element is set to true. If the debug attribute is true, change the debug attribute to false.
The default value is false, but beware of ASP.NET Configuration File Hierarchy and Inheritance. If you use the the IIS configuration editor, you can see the actual values. A drop down list allows you to inspect the values set at a higher level. You can see that the value of debug=true.
debug=true is for debugging during development. It creates debugging symbols used to provide metadata about the current executing code. debug=false is is for deployment to a production server.
This is the transform that is applied when you publish your application to the development staging environment. This would make changes to the web. config which are required for the target environment.
The HttpContext.IsDebuggingEnabled
property:
using System.Web; if (HttpContext.Current.IsDebuggingEnabled) { /* ... */ }
From the documentation:
Gets a value indicating whether the current HTTP request is in debug mode[…]
true
if the request is in debug mode; otherwise,false
.
This should get you the <compilation>
element in the <system.web>
section group:
using System.Web.Configuration ; . . . CompilationSection compilationSection = (CompilationSection)System.Configuration.ConfigurationManager.GetSection(@"system.web/compilation") ; . . . // check the DEBUG attribute on the <compilation> element bool isDebugEnabled = compilationSection.Debug ;
Easy!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With