0

I have many services with the same main path, so I'm looking to add the main path to app settings keys and access it on baseAddress.

just as below code, what I could use instead of {baseAddress}?

<appSettings>
    <add key="baseAddresses"value="https://localhost:4434/X/"/>
  </appSettings>
  
  <service name="X.Services.Proxy.MOF" behaviorConfiguration="restServiceBehave">
        <host>
          <baseAddresses>
            <add baseAddress="{baseAddresses}/MOF.svc" />
          </baseAddresses>
        </host>
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="rest" bindingConfiguration="NormalRequestBinding" contract="X.Services.Proxy.MOF" name="MOF" />
      </service>
Noor Shaker
  • 37
  • 1
  • 6
  • Does this answer your question? [Reading settings from app.config or web.config in .NET](https://stackoverflow.com/questions/1189364/reading-settings-from-app-config-or-web-config-in-net) – Alex Aug 16 '22 at 11:40
  • No, I need to access it inside web.config, not from executable file. – Noor Shaker Aug 16 '22 at 11:44
  • I'm afraid there's not built in way to do that. There are custom options though https://stackoverflow.com/questions/603009/variables-within-app-config-web-config – Alex Aug 16 '22 at 11:49
  • ConfigurationManager.AppSettings["configFile"] https://stackoverflow.com/questions/8147220/how-to-read-appsettings-section-in-the-web-config-file – Ítallo Rian Aug 16 '22 at 12:43

1 Answers1

0

You can do it:

ConfigurationManager.AppSettings["{your_key}"]