CSLA .NET

From Rockford Lhotka's Expert C# 2005 and VB 2005 Business Objects books

Welcome to CSLA .NET Sign in | Join | Help
in Search

Multiple WCF services within single host returning root appsettings and not local

Last post 09-05-2008, 9:38 PM by RockfordLhotka. 1 replies.
Sort Posts: Previous Next
  •  09-05-2008, 3:12 AM 25954

    Multiple WCF services within single host returning root appsettings and not local

    I have a 2 WCF services contained within a WCF WebApplication project hosted in Visual Studio Development server.

    Folder structure looks like:

    WCFHost <Root Folder>

    ModuleA <Folder1>

          1) ModuleA_Service.svc + .cs

          2) IModuleA_Service.cs

       3) web.config <moduleA config which has ServiceModel settings and overridden appSettings>

    ModuleB <Folder2>

          1) ModuleB_Service.svc + .cs

          2) IModuleB_Service.cs

       3) web.config <moduleB config which has ServiceModel settings and overridden appSettings>

    1) web.config <root config>

     

    Root web.config

    --------------------------

    <appSettings>

    <add key="ClientName" value="ROOT"/>

    </appSettings>

     

    ModuleA config

    --------------------

    <appSettings>

    <add key="ClientName" value="Module A"/>

    </appSettings>

     

    ModuleB config

    ------------------------

    <appSettings>

    <add key="ClientName" value="Module B"/>

    </appSettings>
     


    The services for both ModuleA and ModuleB simply returns the config value (note this is just a sample application, just illustrating the problem)

    public string GetSetting()

    {

    return System.Configuration.ConfigurationManager.AppSettings["ClientName"];

    }

    The problem is that the service(which does work fine) returns the appsetting found in the root "clientName='root' " rather than the appsetting stored under its sibling web.config file which should read "clientName='Module A' ". Note the serviceModel settings are on the config files next to the .svc files. So it is using the right config file for the service setup but using the incorrect appsetting.

  •  09-05-2008, 9:38 PM 25989 in reply to 25954

    Re: Multiple WCF services within single host returning root appsettings and not local

    The config file management is handled by ASP.NET. You'll need to research how ASP.NET handles the appSettings block in cases like this (I don't know the answer).


    Rocky
View as RSS news feed in XML

Please contact Magenic for your .NET consulting and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Powered by Community Server, by Telligent Systems