• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 570
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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