2011-10-27 11 views
2

webHttpBindingのkeepAliveを無効にする方法が不思議です。プログラムでWebHttpBindingのキープアライブを設定する

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

同じことをプログラムで行うにはどうすればよいですか?

答えて

4
private Binding CreateBinding() 
{ 
    Binding binding = new WebHttpBinding(); 

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

    return customBinding; 
} 
関連する問題