Home All Groups Group Topic Archive Search About

Cannot get Application Setting

Author
10 Oct 2006 10:19 AM
vvenk
Hello:

I've defined two application settings in my web.config file. But in the
following code :

        Dim rootWebConfig1 As System.Configuration.Configuration
        rootWebConfig1 =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Nothing)
        If (rootWebConfig1.AppSettings.Settings.Count > 0) Then

            sField1 = rootWebConfig1.AppSettings.Settings("field1")
            sField2 = rootWebConfig1.AppSettings.Settings("field2")

        End If

rootWebConfig1.AppSettings.Settings.Count  always returns 0.

What am I doing wrong?

Venki

Author
20 Oct 2006 12:25 PM
dcp12345678
> What am I doing wrong?

The code Microsoft provides doesn't work.  I had the exact same problem
you did.

You can use AppSettings.Item("YourKeyHere") to get the value.