2

I want to share a folder between two web applications, so I tried to do the following:

<add key="SharedFolder" value="D:\tfs\PlacasV1\Aplicacion Placas DataCenter\Integracion.Reclamos\Web-PRbranch1\"/>
<add key="Claims.ControlGen.OutputDir" value="SharedFolder\restricted\controls\generated\"/>
<add key="Claims.ControlGen.CsTemplatePath" value="SharedFolder\restricted\templates\CustomFieldsControl.ascx.cs.temp"/>
<add key="Claims.ControlGen.AscxTemplatePath" value="SharedFolder\restricted\templates\CustomFieldsControl.ascx.temp.xhtml"/>
<add key="Claims.CodeGeneration.ExpressionValidatorTemplatePath" value="SharedFolder\restricted\templates\ClaimsExpressionValidator.cs.temp"/>
<add key="Claims.CodeGeneration.SrcOutputPath" value="SharedFolder\App_Code\"/>
<add key="Claims.CodeGeneration.DatatypeTemplatePath" value="SharedFolder\restricted\templates\CaseExtensionData.cs.temp"/>
<add key="Claims.CodeGeneration.LibDir" value="SharedFolder\bin"/>
<add key="Claims.Xsl.Dir" value="SharedFolder\restricted\xsl\"/>

Any Ideas?

Thanks!

Chains
  • 11,681
  • 8
  • 40
  • 61
Jonathan Escobedo
  • 3,727
  • 12
  • 67
  • 89
  • Short answer - no. Long answer - read this for some custom ways of doing it: http://stackoverflow.com/questions/603009/variables-within-app-config-web-config – Mrchief Aug 12 '11 at 23:08
  • Possible duplicate of http://stackoverflow.com/q/603009/542398 – Chains Aug 12 '11 at 23:50

3 Answers3

2

You can create a custom configuration section, and design it to do what you're looking for, in some way or the other.

See this article for details on how to create custom configuration sections:

http://msdn.microsoft.com/en-us/library/2tw134k3.aspx

Here is an example of a custom configuration section that I created in one of our applications. Just design the section to accomodate your needs, and it should work like a charm:

public class ImportConfiguration : ConfigurationSection
{
    [ConfigurationProperty("importMap")]
    public ImportMapElementCollection ImportMap
    {
        get
        {
            return this["importMap"] as ImportMapElementCollection;
        }
    }
}

public class ImportColumnMapElement : ConfigurationElement
{
    [ConfigurationProperty("localName", IsRequired = true, IsKey = true)]
    public string LocalName
    {
        get
        {
            return this["localName"] as string;
        }
        set
        {
            this["localName"] = value;
        }
    }

    [ConfigurationProperty("sourceName", IsRequired = true)]
    public string SourceName
    {
        get
        {
            return this["sourceName"] as string;
        }
        set
        {
            this["sourceName"] = value;
        }
    }
}

public class ImportMapElementCollection : ConfigurationElementCollection
{
    public ImportColumnMapElement this[object key]
    {
        get
        {
            return base.BaseGet(key) as ImportColumnMapElement;
        }
    }

    public override ConfigurationElementCollectionType CollectionType
    {
        get
        {
            return ConfigurationElementCollectionType.BasicMap;
        }
    }

    protected override string ElementName
    {
        get
        {
            return "columnMap";
        }
    }

    protected override bool IsElementName(string elementName)
    {
        bool isName = false;
        if (!String.IsNullOrEmpty(elementName))
            isName = elementName.Equals("columnMap");
        return isName;
    }

    protected override ConfigurationElement CreateNewElement()
    {
        return new ImportColumnMapElement();
    }

    protected override object GetElementKey(ConfigurationElement element)
    {
        return ((ImportColumnMapElement)element).LocalName;
    }
}
James Johnson
  • 43,670
  • 6
  • 67
  • 106
1

You can't do this out of the box. I would suggest you to have look at DslConfig.

With DslConfig you can configure something like:

sharedFolder = "D:\tfs\PlacasV1\Aplicacion Placas DataCenter\Integracion.Reclamos\Web-PRbranch1\"
Var["SharedFolder"] = sharedFolder
Var["Claims.ControlGen.OutputDir"] = sharedFolder + "restricted\controls\generated\"

You can access the configuration with:

var config = new DslConfig.BooDslConfiguration();
config.GetVariable<string>("SharedFolder");
config.GetVariable<string>("Claims.ControlGen.OutputDir");
Uwe Keim
  • 36,867
  • 50
  • 163
  • 268
Johannes
  • 77
  • 1
0

You can read the values from a xml file that can be accessed by both applications

Martin
  • 1,491
  • 3
  • 18
  • 35