简体   繁体   中英

Can I concat an endpoint address to a variable in app.config file?

Is this possible in appconfig file?

<add key="@IPAddress" value="http://00.00.00.00:0000"/>

replace this:

<endpoint address="http://00.00.00.00:0000/some/something"
               binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding"

with this:

<endpoint address="@IPaddress/some/something"
               binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding"

You can't do it in config. But you can change your address in runtime, like this

var confAddress=ConfigurationManager.AppSettings["IPAddress"];
string address = confAddress+"/some/something";
using (ServiceHost serviceHost = new ServiceHost(typeof(yourContract), address))
{
   //Consume your service
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM