首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >以编程方式为WebHttpBinding设置keep-alive

以编程方式为WebHttpBinding设置keep-alive
EN

Stack Overflow用户
提问于 2011-10-28 05:34:13
回答 1查看 1.4K关注 0票数 2

我想知道如何为webHttpBinding禁用keepAlive。我知道我可以这样做:

代码语言:javascript
复制
<bindings>
<customBinding>
    <binding name="WebHttpWithoutKeepAlive">
        <webMessageEncoding />
        <httpTransport keepAliveEnabled="false" />
    </binding>
</customBinding>
</bindings>
<services>
<service name="MyService" behaviorConfiguration="myServiceBehavior">
<endpoint address="http://localhost:9005/"
      binding="customBinding"
      bindingConfiguration="WebHttpWithoutKeepAlive"
      contract="IMyService"
      behaviorConfiguration="myServerEndpointBehavior"/>
</service>
</services>

我怎样才能以编程方式做同样的事情呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-26 17:57:42

代码语言:javascript
复制
private Binding CreateBinding()
{
    Binding binding = new WebHttpBinding();

    CustomBinding customBinding = new CustomBinding(binding);
    var transportElement = customBinding.Elements.Find<HttpTransportBindingElement>();
    transportElement.KeepAliveEnabled = false;

    return customBinding;
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7922713

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档