是否可以以编程方式更改WCF绑定地址? [英] Is it possible to change WCF binding address programatically?

查看:84
本文介绍了是否可以以编程方式更改WCF绑定地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的asp .net网站配置文件中,我配置了servcie。



在各种服务器上配置相同的服务。

In我的网站我有各种服务器的标签。因此,当点击该选项卡时,网站会自动选择特定的服务端点并执行操作。



所以任何人都有这个想法,我怎么能实现这个?



In my asp .net website config file,i configured the servcie.

The same servcie configured on various servers.
In my website i have various tabs that is for various servers. So while clicking on that tab,website automatically select particular service endpoint and perform the operation.

So anybody have idea on this ,how may i achive this?

<client>
     <endpoint address=""
         binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
         contract="IService" name="BasicHttpBinding_IService" />
   </client>

推荐答案

是的你可以。查看以下详细信息以获取更多信息。



Yes you can.Check below details for more info.

引用:

我认为您想要的是在运行时换出配置文件的一个版本,如果是这样的话,请创建一个配置文件的副本(同时给它相应的扩展名,如.Debug或。 Release)具有正确的地址(为您提供调试版本和运行时版本)并创建一个postbuild步骤,根据构建类型复制正确的文件。



这是我过去使用的postbuild事件的一个示例,它使用正确的版本(调试/运行时)覆盖输出文件

I think what you want is to swap out at runtime a version of your config file, if so create a copy of your config file (also give it the relevant extension like .Debug or .Release) that has the correct addresses (which gives you a debug version and a runtime version ) and create a postbuild step that copies the correct file depending on the build type.

Here is an example of a postbuild event that I've used in the past which overrides the output file with the correct version (debug/runtime)







copy "


(项目Dir)ServiceReferences.ClientConfig。
(ProjectDir)ServiceReferences.ClientConfig.


(ConfigurationName)
(ConfigurationName)" "


这篇关于是否可以以编程方式更改WCF绑定地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆