• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 571
  • Last Modified:

codebehind - find a web config value (compile debug)

From my web config:

<compilation debug="false">


How do I find-out what this value is set to in my code behind?
0
Tom Knowlton
Asked:
Tom Knowlton
3 Solutions
 
meispiscesCommented:
Not sure about your question.
0
 
Erick37Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
???

I have to load it in as an XML file?

Doesn't .NET have built-in support for reading in web.config values?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Kumaraswamy RCommented:
0
 
Erick37Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
thx
0
 
Erick37Commented:
No problem.

I see "Not sure about your question." was also helpful.  :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now