我想知道如何为webHttpBinding禁用keepAlive。我知道我可以这样做:
<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>我怎样才能以编程方式做同样的事情呢?
发布于 2012-09-26 17:57:42
private Binding CreateBinding()
{
Binding binding = new WebHttpBinding();
CustomBinding customBinding = new CustomBinding(binding);
var transportElement = customBinding.Elements.Find<HttpTransportBindingElement>();
transportElement.KeepAliveEnabled = false;
return customBinding;
}https://stackoverflow.com/questions/7922713
复制相似问题