473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

reading web.config in Visual Studio 2005

The code below is directly from Microsoft's help. It describes how to
read a value from the Web.config file. I tried out this code and it
does not appear to work (at least when I try it).

If my web.config file I have the following:
<appSettings>
<add key="WebServer" value="localhost"/>
</appSettings>

I want to read out the WebServer value and I used Microsoft's code
below. But again, it doesn't work. However, just doing
AppSettings.Item("WebServer") did the trick. I have no idea why
Microsoft's code below doesn't work. Anybody want to try and explain?

Dim rootWebConfig1 As System.Configuration.Configuration
rootWebConfig1 =
System.Web.Configuration.WebConfigurationManager.O penWebConfiguration(Nothing)
If (0 < rootWebConfig1.AppSettings.Settings.Count) Then
Dim customSetting As
System.Configuration.KeyValueConfigurationElement
customSetting =
rootWebConfig1.AppSettings.Settings("customsetting 1")
If Not (Nothing = customSetting.Value) Then
Console.WriteLine("customsetting1 application string = {0}",
customSetting.Value)
Else
Console.WriteLine("No customsetting1 application string")
End If
End If

Oct 19 '06 #1
0 1204

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul Daly (MCP) | last post by:
I've created a windows forms appliation that gets its data from a sql database. I want to create an app.config file for this application so that in the event that the server name changes, they...
3
by: jason | last post by:
i am coding a simple console application with Visual C# .NET in Visual Studio .NET my config file (myapp.exe.config) has the following appSettings section: <appSettings> <add key="myKey"...
5
by: sck10 | last post by:
Hello, I just installed Visual Web Developer Beta 2 and got the following error from an application that was created with Beta 1. Any help would be appreciated: <compilation...
26
by: S. Justin Gengo | last post by:
I installed the release of Visual Studio.NET 2005 Professional a few days ago. I've been using the Beta for a few weeks and one immediate problem is that I don't seem to have full intellisense in...
10
by: RedLars | last post by:
Hi, Have a question about an AppSetting's file in VS2005. Under Assembly \ Properties I got a Settings.settings which contains a table of name, type, value etc. I also got a App.Config file in...
13
by: Jonny Bergdahl | last post by:
I have a ASP.Net 2.0 web application that I am trying to debug. Problem is that I can't get the error message to show in the browser. It always returns the generic error message telling me to set...
4
by: =?Utf-8?B?Znc=?= | last post by:
Is there a way to config a asp.net app subdir's web.config so that the sub dir becomes a new IIS application in Visual Studio 2005? I need this because the authentication mode for the subdir is...
10
by: =?Utf-8?B?TUNN?= | last post by:
When creating a new VB Web Application Project with VS2008, there are several settings (compiler settings, option strict, etc) that appear both in the web.config file and "My Project". I'm...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I cut and paste the following code from msdn help page which it just introduces view and multiview server controls. Here is what I do: in vs studio 2005, File --New Web Site, it...
1
by: Nathan Sokalski | last post by:
On Microsoft's page about IE8 and Defining Document Compatibility at: http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx They give the following code to add to Web.config: <?xml...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.