Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

codebehind - find a web config value (compile debug)

Posted on 2010-11-22
7
562 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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