Solved

codebehind - find a web config value (compile debug)

Posted on 2010-11-22
7
556 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now