reading Web.config with ConfigurationSetting HELP??

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default reading Web.config with ConfigurationSetting HELP??

    I have a Winforms app and a WebService. When the win app calls
    the service, the service reads the config file like so

    ConfigurationSettings.AppSettings["myKey"]

    but, the WebService is getting the app.config from the win app
    NOT the Web.config settings.

    Read:: Accessing ASP.NET Configuration Settings and it states to
    use ConfigurationSettings.AppSettings, so why wont it read Web.config ?

    thanks,

    JIM





    james Guest

  2. Similar Questions and Discussions

    1. Reading Values from Machine.config in ASP.NET
      How can i read values from Machine.config From ASP.NET
    2. Error loading XML file c:\windows\microsoft.net\framework\v1.0.3705\Config\machine.config
      I had many ASP.NET web applications that I created before I had to rebuild my machine. After a fresh install of XP Pro, VS.NET 2003, etc, I now...
    3. config file: a) what Module ? b) conditionals in config (for multiple hosts)
      Hi, a) I am looking for a module to handle config files. There are a number of these modules, like AppCconig. Any consensus about The Right...
    4. [RCR] Include CONFIG::Config['rubydocdir'] in rbconfig.rb
      Hi folks, I apologise if people have read this RCR and are not interested, but this is what I consider to be an important RCR, not a merely...
    5. Intermittent problem reading appSettings in Web.Config
      Are you positive this is a web config issue? You yourself say you don't know what is being returned. When you resave web.config, this restarts...
  3. #2

    Default Re: reading Web.config with ConfigurationSetting HELP??

    Are you sure you are accessing the webservice through SOAP? The webservice
    indeed should read the web.config file! I'm pretty sure it does (normally)
    because I've done this numerous times...

    In fact I don't think it's possible due to a number of issues (security,
    application boundaries, ...).

    --
    Greetz

    Jan Tielens
    ________________________________
    Read my weblog: [url]http://weblogs.asp.net/jan[/url]


    "james" <nospam@hypercon.net> wrote in message
    news:eGvQmiY8DHA.1636@TK2MSFTNGP12.phx.gbl...
    > I have a Winforms app and a WebService. When the win app calls
    > the service, the service reads the config file like so
    >
    > ConfigurationSettings.AppSettings["myKey"]
    >
    > but, the WebService is getting the app.config from the win app
    > NOT the Web.config settings.
    >
    > Read:: Accessing ASP.NET Configuration Settings and it states to
    > use ConfigurationSettings.AppSettings, so why wont it read Web.config ?
    >
    > thanks,
    >
    > JIM
    >
    >
    >
    >
    >

    Jan Tielens Guest

  4. #3

    Default Re: reading Web.config with ConfigurationSetting HELP??

    Well, I follow the MS example on creating an WebService. Simply reference
    the web service and call the properties in the object like so

    value = MyWebService.MyObject.SomeStaticProperty()

    now inside SomeStaticProperty() I do this

    public class Util : System.Web.Services.WebService
    {

    ....
    [WebMethod(Description="Does something", EnableSession=false)]
    public static string SomeStaticProperty()
    {
    return ConfigurationSettings.AppSettings["SomeValue"];
    }


    and the XML in Web.config

    .....
    <appSettings>
    <add key="SomeValue" value="xxxxx" />
    </appSettings>


    thanks for the help



    "Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
    news:eLQgw0i8DHA.1672@TK2MSFTNGP12.phx.gbl...
    > Are you sure you are accessing the webservice through SOAP? The webservice
    > indeed should read the web.config file! I'm pretty sure it does (normally)
    > because I've done this numerous times...
    >
    > In fact I don't think it's possible due to a number of issues (security,
    > application boundaries, ...).
    >
    > --
    > Greetz
    >
    > Jan Tielens
    > ________________________________
    > Read my weblog: [url]http://weblogs.asp.net/jan[/url]
    >
    >
    > "james" <nospam@hypercon.net> wrote in message
    > news:eGvQmiY8DHA.1636@TK2MSFTNGP12.phx.gbl...
    > > I have a Winforms app and a WebService. When the win app calls
    > > the service, the service reads the config file like so
    > >
    > > ConfigurationSettings.AppSettings["myKey"]
    > >
    > > but, the WebService is getting the app.config from the win app
    > > NOT the Web.config settings.
    > >
    > > Read:: Accessing ASP.NET Configuration Settings and it states to
    > > use ConfigurationSettings.AppSettings, so why wont it read Web.config ?
    > >
    > > thanks,
    > >
    > > JIM
    > >
    > >
    > >
    > >
    > >
    >
    >

    james Guest

  5. #4

    Default Re: reading Web.config with ConfigurationSetting HELP??

    How do you call that static property?

    --
    Greetz

    Jan Tielens
    ________________________________
    Read my weblog: [url]http://weblogs.asp.net/jan[/url]


    "james" <nospam@hypercon.net> wrote in message
    news:eSYRdak8DHA.1640@TK2MSFTNGP11.phx.gbl...
    > Well, I follow the MS example on creating an WebService. Simply
    reference
    > the web service and call the properties in the object like so
    >
    > value = MyWebService.MyObject.SomeStaticProperty()
    >
    > now inside SomeStaticProperty() I do this
    >
    > public class Util : System.Web.Services.WebService
    > {
    >
    > ...
    > [WebMethod(Description="Does something", EnableSession=false)]
    > public static string SomeStaticProperty()
    > {
    > return ConfigurationSettings.AppSettings["SomeValue"];
    > }
    >
    >
    > and the XML in Web.config
    >
    > ....
    > <appSettings>
    > <add key="SomeValue" value="xxxxx" />
    > </appSettings>
    >
    >
    > thanks for the help
    >
    >
    >
    > "Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
    > news:eLQgw0i8DHA.1672@TK2MSFTNGP12.phx.gbl...
    > > Are you sure you are accessing the webservice through SOAP? The
    webservice
    > > indeed should read the web.config file! I'm pretty sure it does
    (normally)
    > > because I've done this numerous times...
    > >
    > > In fact I don't think it's possible due to a number of issues (security,
    > > application boundaries, ...).
    > >
    > > --
    > > Greetz
    > >
    > > Jan Tielens
    > > ________________________________
    > > Read my weblog: [url]http://weblogs.asp.net/jan[/url]
    > >
    > >
    > > "james" <nospam@hypercon.net> wrote in message
    > > news:eGvQmiY8DHA.1636@TK2MSFTNGP12.phx.gbl...
    > > > I have a Winforms app and a WebService. When the win app calls
    > > > the service, the service reads the config file like so
    > > >
    > > > ConfigurationSettings.AppSettings["myKey"]
    > > >
    > > > but, the WebService is getting the app.config from the win app
    > > > NOT the Web.config settings.
    > > >
    > > > Read:: Accessing ASP.NET Configuration Settings and it states to
    > > > use ConfigurationSettings.AppSettings, so why wont it read Web.config
    ?
    > > >
    > > > thanks,
    > > >
    > > > JIM
    > > >
    > > >
    > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Jan Tielens Guest

  6. #5

    Default Re: reading Web.config with ConfigurationSetting HELP??

    Jan,

    See below, the line that says this::
    > > value = MyWebService.MyObject.SomeStaticProperty()

    is this wrong ?

    thanks,

    JIM


    "Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
    news:#0WivpF9DHA.3292@TK2MSFTNGP11.phx.gbl...
    > How do you call that static property?
    >
    > --
    > Greetz
    >
    > Jan Tielens
    > ________________________________
    > Read my weblog: [url]http://weblogs.asp.net/jan[/url]
    >
    >
    > "james" <nospam@hypercon.net> wrote in message
    > news:eSYRdak8DHA.1640@TK2MSFTNGP11.phx.gbl...
    > > Well, I follow the MS example on creating an WebService. Simply
    > reference
    > > the web service and call the properties in the object like so
    > >
    > > value = MyWebService.MyObject.SomeStaticProperty()
    > >
    > > now inside SomeStaticProperty() I do this
    > >
    > > public class Util : System.Web.Services.WebService
    > > {
    > >
    > > ...
    > > [WebMethod(Description="Does something", EnableSession=false)]
    > > public static string SomeStaticProperty()
    > > {
    > > return ConfigurationSettings.AppSettings["SomeValue"];
    > > }
    > >
    > >
    > > and the XML in Web.config
    > >
    > > ....
    > > <appSettings>
    > > <add key="SomeValue" value="xxxxx" />
    > > </appSettings>
    > >
    > >
    > > thanks for the help
    > >
    > >
    > >
    > > "Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
    > > news:eLQgw0i8DHA.1672@TK2MSFTNGP12.phx.gbl...
    > > > Are you sure you are accessing the webservice through SOAP? The
    > webservice
    > > > indeed should read the web.config file! I'm pretty sure it does
    > (normally)
    > > > because I've done this numerous times...
    > > >
    > > > In fact I don't think it's possible due to a number of issues
    (security,
    > > > application boundaries, ...).
    > > >
    > > > --
    > > > Greetz
    > > >
    > > > Jan Tielens
    > > > ________________________________
    > > > Read my weblog: [url]http://weblogs.asp.net/jan[/url]
    > > >
    > > >
    > > > "james" <nospam@hypercon.net> wrote in message
    > > > news:eGvQmiY8DHA.1636@TK2MSFTNGP12.phx.gbl...
    > > > > I have a Winforms app and a WebService. When the win app calls
    > > > > the service, the service reads the config file like so
    > > > >
    > > > > ConfigurationSettings.AppSettings["myKey"]
    > > > >
    > > > > but, the WebService is getting the app.config from the win app
    > > > > NOT the Web.config settings.
    > > > >
    > > > > Read:: Accessing ASP.NET Configuration Settings and it states to
    > > > > use ConfigurationSettings.AppSettings, so why wont it read
    Web.config
    > ?
    > > > >
    > > > > thanks,
    > > > >
    > > > > JIM
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    james Guest

  7. #6

    Default Re: reading Web.config with ConfigurationSetting HELP??

    Aah, I see the problem! I think you are using your web service directly. You
    should add a web reference to your web service (not a normal reference) and
    then use the following code:

    Dim s As New referenceName.MyObject
    value = s.SomeStaticProperty

    Also, I think the static keyword doesn't make any sense when using a web
    service:
    public static string SomeStaticProperty()
    should be
    public string SomeStaticProperty()
    --
    Greetz

    Jan Tielens
    ________________________________
    Read my weblog: [url]http://weblogs.asp.net/jan[/url]


    "james" <nospam@hypercon.net> wrote in message
    news:uMkmXGK9DHA.2944@TK2MSFTNGP11.phx.gbl...
    > Jan,
    >
    > See below, the line that says this::
    > > > value = MyWebService.MyObject.SomeStaticProperty()
    >
    >
    > is this wrong ?
    >
    > thanks,
    >
    > JIM
    >
    >
    > "Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
    > news:#0WivpF9DHA.3292@TK2MSFTNGP11.phx.gbl...
    > > How do you call that static property?
    > >
    > > --
    > > Greetz
    > >
    > > Jan Tielens
    > > ________________________________
    > > Read my weblog: [url]http://weblogs.asp.net/jan[/url]
    > >
    > >
    > > "james" <nospam@hypercon.net> wrote in message
    > > news:eSYRdak8DHA.1640@TK2MSFTNGP11.phx.gbl...
    > > > Well, I follow the MS example on creating an WebService. Simply
    > > reference
    > > > the web service and call the properties in the object like so
    > > >
    > > > value = MyWebService.MyObject.SomeStaticProperty()
    > > >
    > > > now inside SomeStaticProperty() I do this
    > > >
    > > > public class Util : System.Web.Services.WebService
    > > > {
    > > >
    > > > ...
    > > > [WebMethod(Description="Does something", EnableSession=false)]
    > > > public static string SomeStaticProperty()
    > > > {
    > > > return ConfigurationSettings.AppSettings["SomeValue"];
    > > > }
    > > >
    > > >
    > > > and the XML in Web.config
    > > >
    > > > ....
    > > > <appSettings>
    > > > <add key="SomeValue" value="xxxxx" />
    > > > </appSettings>
    > > >
    > > >
    > > > thanks for the help
    > > >
    > > >
    > > >
    > > > "Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
    > > > news:eLQgw0i8DHA.1672@TK2MSFTNGP12.phx.gbl...
    > > > > Are you sure you are accessing the webservice through SOAP? The
    > > webservice
    > > > > indeed should read the web.config file! I'm pretty sure it does
    > > (normally)
    > > > > because I've done this numerous times...
    > > > >
    > > > > In fact I don't think it's possible due to a number of issues
    > (security,
    > > > > application boundaries, ...).
    > > > >
    > > > > --
    > > > > Greetz
    > > > >
    > > > > Jan Tielens
    > > > > ________________________________
    > > > > Read my weblog: [url]http://weblogs.asp.net/jan[/url]
    > > > >
    > > > >
    > > > > "james" <nospam@hypercon.net> wrote in message
    > > > > news:eGvQmiY8DHA.1636@TK2MSFTNGP12.phx.gbl...
    > > > > > I have a Winforms app and a WebService. When the win app calls
    > > > > > the service, the service reads the config file like so
    > > > > >
    > > > > > ConfigurationSettings.AppSettings["myKey"]
    > > > > >
    > > > > > but, the WebService is getting the app.config from the win app
    > > > > > NOT the Web.config settings.
    > > > > >
    > > > > > Read:: Accessing ASP.NET Configuration Settings and it states to
    > > > > > use ConfigurationSettings.AppSettings, so why wont it read
    > Web.config
    > > ?
    > > > > >
    > > > > > thanks,
    > > > > >
    > > > > > JIM
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Jan Tielens Guest

  8. #7

    Default Re: reading Web.config with ConfigurationSetting HELP??

    Jan,

    I changed the methods to non static, and instantiated my webservice i.e.
    C#
    MyWebSevice.MyUtility utility = new MyWebSevice.MyUtility();

    so now the calls look like this

    string setting = utility.GetSomeAppSetting();

    but guess what ? It still gets the app setting from the calling app
    not the Web.config !

    Sorry, any other ideas??

    MVP ???


    thanks for your help

    JIM

    "Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
    news:ez#0LTS9DHA.1632@TK2MSFTNGP12.phx.gbl...
    > Aah, I see the problem! I think you are using your web service directly.
    You
    > should add a web reference to your web service (not a normal reference)
    and
    > then use the following code:
    >
    > Dim s As New referenceName.MyObject
    > value = s.SomeStaticProperty
    >
    > Also, I think the static keyword doesn't make any sense when using a web
    > service:
    > public static string SomeStaticProperty()
    > should be
    > public string SomeStaticProperty()
    > --
    > Greetz
    >
    > Jan Tielens
    > ________________________________
    > Read my weblog: [url]http://weblogs.asp.net/jan[/url]
    >
    >
    > "james" <nospam@hypercon.net> wrote in message
    > news:uMkmXGK9DHA.2944@TK2MSFTNGP11.phx.gbl...
    > > Jan,
    > >
    > > See below, the line that says this::
    > > > > value = MyWebService.MyObject.SomeStaticProperty()
    > >
    > >
    > > is this wrong ?
    > >
    > > thanks,
    > >
    > > JIM
    > >
    > >
    > > "Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
    > > news:#0WivpF9DHA.3292@TK2MSFTNGP11.phx.gbl...
    > > > How do you call that static property?
    > > >
    > > > --
    > > > Greetz
    > > >
    > > > Jan Tielens
    > > > ________________________________
    > > > Read my weblog: [url]http://weblogs.asp.net/jan[/url]
    > > >
    > > >
    > > > "james" <nospam@hypercon.net> wrote in message
    > > > news:eSYRdak8DHA.1640@TK2MSFTNGP11.phx.gbl...
    > > > > Well, I follow the MS example on creating an WebService. Simply
    > > > reference
    > > > > the web service and call the properties in the object like so
    > > > >
    > > > > value = MyWebService.MyObject.SomeStaticProperty()
    > > > >
    > > > > now inside SomeStaticProperty() I do this
    > > > >
    > > > > public class Util : System.Web.Services.WebService
    > > > > {
    > > > >
    > > > > ...
    > > > > [WebMethod(Description="Does something", EnableSession=false)]
    > > > > public static string SomeStaticProperty()
    > > > > {
    > > > > return ConfigurationSettings.AppSettings["SomeValue"];
    > > > > }
    > > > >
    > > > >
    > > > > and the XML in Web.config
    > > > >
    > > > > ....
    > > > > <appSettings>
    > > > > <add key="SomeValue" value="xxxxx" />
    > > > > </appSettings>
    > > > >
    > > > >
    > > > > thanks for the help
    > > > >
    > > > >
    > > > >
    > > > > "Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
    > > > > news:eLQgw0i8DHA.1672@TK2MSFTNGP12.phx.gbl...
    > > > > > Are you sure you are accessing the webservice through SOAP? The
    > > > webservice
    > > > > > indeed should read the web.config file! I'm pretty sure it does
    > > > (normally)
    > > > > > because I've done this numerous times...
    > > > > >
    > > > > > In fact I don't think it's possible due to a number of issues
    > > (security,
    > > > > > application boundaries, ...).
    > > > > >
    > > > > > --
    > > > > > Greetz
    > > > > >
    > > > > > Jan Tielens
    > > > > > ________________________________
    > > > > > Read my weblog: [url]http://weblogs.asp.net/jan[/url]
    > > > > >
    > > > > >
    > > > > > "james" <nospam@hypercon.net> wrote in message
    > > > > > news:eGvQmiY8DHA.1636@TK2MSFTNGP12.phx.gbl...
    > > > > > > I have a Winforms app and a WebService. When the win app calls
    > > > > > > the service, the service reads the config file like so
    > > > > > >
    > > > > > > ConfigurationSettings.AppSettings["myKey"]
    > > > > > >
    > > > > > > but, the WebService is getting the app.config from the win app
    > > > > > > NOT the Web.config settings.
    > > > > > >
    > > > > > > Read:: Accessing ASP.NET Configuration Settings and it states to
    > > > > > > use ConfigurationSettings.AppSettings, so why wont it read
    > > Web.config
    > > > ?
    > > > > > >
    > > > > > > thanks,
    > > > > > >
    > > > > > > JIM
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    james Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139