Solved

codebehind - find a web config value (compile debug)

Posted on 2010-11-22
7
558 Views
Last Modified: 2012-05-10
From my web config:

<compilation debug="false">


How do I find-out what this value is set to in my code behind?
0
Comment
Question by:knowlton
7 Comments
 
LVL 7

Assisted Solution

by:meispisces
meispisces earned 20 total points
ID: 34190911
Not sure about your question.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 34191028
Read the setting manually:
Dim doc As XmlDocument = New XmlDocument()
		doc.Load(MapPath("\web.config"))
		Dim compile As XmlNode = doc.DocumentElement.SelectSingleNode("system.web/compilation")

		If compile.Attributes("debug").InnerText.ToLower = "true" Then
			Debug.WriteLine("compilation=true")
		Else
			Debug.WriteLine("compilation=false")
		End If

Open in new window

0
 
LVL 5

Author Comment

by:knowlton
ID: 34191925
???

I have to load it in as an XML file?

Doesn't .NET have built-in support for reading in web.config values?
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 29

Assisted Solution

by:Kumaraswamy R
Kumaraswamy R earned 200 total points
ID: 34194279
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 280 total points
ID: 34200413
Another way:

Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)
Dim section As System.Web.Configuration.CompilationSection = config.GetSection("system.web/compilation")
''read the Debug section
Response.Write(String.Format("Debug={0}", section.Debug))
0
 
LVL 5

Author Closing Comment

by:knowlton
ID: 34241598
thx
0
 
LVL 32

Expert Comment

by:Erick37
ID: 34241897
No problem.

I see "Not sure about your question." was also helpful.  :)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question