如何在web.config中检查Debug是否启用 [英] How do I check if Debug is enabled in web.config
问题描述
ConfigurationSettings.GetConfig(system.web / compilation ).Debug.ToString()
当我想将其转换为C#并在.NET中使用它3.5遇到麻烦,不行。另外,我想使用ConfigurationManager.GetSection的较新的构造。任何人都可以建议如何最好地阅读 system.web / compilation / debug = true | false
value?
赞赏!
使用:
HttpContext.Current.IsDebuggingEnabled
此属性实际上查看了web.config配置设置。如果您使用Reflector查看它,您将发现它使用一些内部类获取实际的ConfigurationSection对象。
I have some code from my VB.NET 1.1 days that allowed me to dynamically check if Debug was enabled in web.config. I figured why re-invent the wheel in turning on/off logging if I could simply have the web administrator enable debug. Here is the code I used in VB.NET that worked just fine:
ConfigurationSettings.GetConfig("system.web/compilation").Debug.ToString()
When I wanted to convert this to C# and use it in .NET 3.5 I ran into some trouble and it wouldn't work. Additionally, I would like to use the newer construct of ConfigurationManager.GetSection. Can anyone suggest how best to read the system.web/compilation/debug=true|false
value?
Much appreciated!
Use:
HttpContext.Current.IsDebuggingEnabled
This property actually looks at the web.config configuration setting. If you look at it using Reflector you will find that it gets the actual ConfigurationSection object using some internal classes.
这篇关于如何在web.config中检查Debug是否启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!