title: HTTP Keep-alive and ServiceHost / C#?
body: <p>How can I enable/disable the HTTP Keep-alive and set the connection timeout of a self hosted service using the application configuration and the C# ServiceHost?</p>
  
  <p>For example,</p>
  
  <pre><code>MyService service = new MyService();
  ServiceHost serviceHost = new ServiceHost(service);
  serviceHost.Open();
  </code></pre>
  
  <p>What do I have to put in the application configuration to set the http keep alive and timeout.</p>
  
  
  
  <pre><code>&lt;configuration&gt;
    &lt;system.serviceModel&gt;
    &lt;services&gt;
      &lt;service name="MyService" behaviorConfiguration="myServiceBehavior"&gt;
      &lt;endpoint address="http://localhost:9005/"
            binding="webHttpBinding"
            contract="IMyService"
            behaviorConfiguration="myServerEndpointBehavior"/&gt;
      &lt;/service&gt;
    &lt;/services&gt;
    &lt;/system.serviceModel&gt;
    &lt;!-- WHERE TO ENABLE/DISABLE http keep alive and timeout --&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The settings under IIS are found if you go to the IIS Manager.  Right click on the "Default Web Site"->Properties->Web Site->Connections.  Can I do that through the system.serviceModel configuration? </p>