Share AppSettings configuration between a service Web and an asp.net web application

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi there,
In a web service (A), I would like to read and modify a web site (B)
configuration file. My goal is only to modify the appSettings section.

In order to avoid mistakes, I would like not to have these settings in the
default web.config file but, say, in a "settings.config" file, located in
the webservice virtual directory.

On IIS6, my webservice A is a web application from the B web site. So, the A
source files are in a (virtual) subdirectory of the B source files
directory.

Does it seem possible ?
___________________________________________________________________________________________________
Now, for a start, I've tried to read the settings in the web.config file of
A:

<?xml version="1.0"?>
<Configuration>
<...>
<appSettings>
<add key="a" value="aaa"/>
</appSettings>
<connectionStrings>
<clear/>
<add name="Stibil" connectionString="Server=.\sql2008..."/>
</connectionStrings>

I use this code:

System.Configuration.Configuration rootWebConfig1 =
WebConfigurationManager.OpenWebConfiguration(null);
if (rootWebConfig1.AppSettings.Settings.Count > 0)
{
KeyValueConfigurationElement customSetting =
rootWebConfig1.AppSettings.Settings[param];
if (customSetting != null)
return customSetting.Value;
}
return "Nothing";

And the fact is that "rootWebConfig1.AppSettings.Settings.Count" returns
0...
However,
"rootWebConfig1.AppSettings.ConnectionStrings..ConnectionStrings.ConnectionStrings.Count"
is 1.

I can't see where is my mistake...

__________________________________________________________________________________________________
Now if I want to read a config file (in my web service or in my web site),
which is not the default "web.config" file, possibly located in a virtual
subdirectory, what parameter do I need in the "OpenWebConfiguration" method
?

Best regards

.



Relevant Pages

  • Re: Pleading Paper - Enveloopes
    ... If you download the envelope templates you can download from my web site ... order to modify them. ... template), since its the styles in Normal.dotm you want to modify. ... I suspect that the double spacing is coming ...
    (microsoft.public.word.newusers)
  • RE: REPOST - web.config and web parts.
    ... Also, based on your description, you may want to simply link to an xml file ... that contains the appSettings tag and appSettings entries like this: ... if you are going to add your own configuration file. ... >> I'd suggest you can put one file under the specified folder as you wish and ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: Envelope Print Question
    ... I did modify the the normal.dotm as I ... wanted to change the default font, margins, and added a footer... ... You could try downloading the envelope samples from my web site. ... Word MVP web site http://word.mvps.org ...
    (microsoft.public.word.docmanagement)
  • Forms Authentication in a subfolder
    ... Our web site is mostly classic ASP. ... application that will reside in a subfolder a few levels deep. ... An error occurred during the processing of a configuration file ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Module name space collision
    ... Each of the config files (MetaManagerTest in the examples below) need to ... The code I have works fine when there is a single web site on my server ... use strict; ... Local Configuration File 1 living at ...
    (perl.beginners)