Solved

codebehind - find a web config value (compile debug)

Posted on 2010-11-22
7
564 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:Tom Knowlton
[X]
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
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:Tom 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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:Tom 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

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…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 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