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



Hi Oriane,

From your description, you want to use code to open the Web.config file of
the IIS root site and modify the AppSettings section in it, correct?

Based on my research, the WebConfigurationManager class can only open
"web.config" file, so if you use your own custom config file, it will not
work with it. And to open the web.config file for the IIS root site, you
only need to supply the root site virutal path which is simply "/"

Here is a test function which open & modify web.config file in IIS site
root(from an ASP.NET application/virtual directory under the site root):

==================

public partial class ConfigTestPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnAddEntry_Click(object sender, EventArgs e)
{
Configuration config =
WebConfigurationManager.OpenWebConfiguration("/");
config.AppSettings.Settings.Add("Item_" + DateTime.Now.Ticks,
"Value_" + DateTime.Now.Ticks);
Response.Write("<br/>Physical path: " + config.FilePath);
config.Save(ConfigurationSaveMode.Modified);
}
}
=================

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
From: "Oriane" <oriane@xxxxxxxxxxxxxxx>
Subject: Share AppSettings configuration between a service Web and an
asp.net web application
Date: Mon, 30 Mar 2009 10:30:28 +0200


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>


.



Relevant Pages

  • RE: Getting settings values in an assermbly library from an ASP.NET or Winform
    ... configuration file for it. ... Create a Class Library named "ClassLibrary1", use the Settings Designer ... Modify app.config: remove the inner content of the tag ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.languages.csharp)
  • PROBLEM: Dell Inspiron 1501 fails to boot in 2.6.21+
    ... My new laptop won't boot with kernel versions 2.6.21 or 2.6.22. ... I've also included my kernel configuration and ver_linux output. ... Enabling unmasked SIMD FPU exception support... ... usbcore: ...
    (Linux-Kernel)
  • 2.6.1-final: Dell Inspiron 8200 still not booting (since 2.6.0-test10)
    ... Note that the same configuration works very ... Dell Inspiron with broken BIOS detected. ... Linux Plug and Play Support v0.97 Adam Belay ... # Device Drivers ...
    (Linux-Kernel)
  • 2.6.20-rt5: serial port trouble?
    ... However, it seems that in 2.6.20-rt5, CONFIG_PREEMPT_RT upsets serial port ... and therefore no network data is sent. ... # ACPI (Advanced Configuration and Power Interface) Support ...
    (Linux-Kernel)
  • 2.6.29-rc libata sff 32bit PIO regression
    ... here's an extract showing the start of the error messages on ata2: ... 871af1210f13966ab911ed2166e4ab2ce775b99d libata: Add 32bit PIO support ... ACPI: PM-Timer IO Port: 0x808 ... Using ACPI for SMP configuration information ...
    (Linux-Kernel)

Quantcast