简体   繁体   English

我可以将端点地址连接到app.config文件中的变量吗?

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

Is this possible in appconfig file? appconfig文件中有可能吗?

<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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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