Solved

codebehind - find a web config value (compile debug)

Posted on 2010-11-22
7
565 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

627 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