WCF/WF - HTTP Keep-alive and ServiceHost / C# - Asked By Nate B on 10-Sep-10 01:46 PM

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?

For example,

MyService service = new MyService();
ServiceHost serviceHost = new ServiceHost(service);
serviceHost.Open();

What do I have to put in the application configuration to set the http keep alive and timeout.

<!-- NOTE: Showing only a portion of the configuration -->
 
<configuration>
  <system.serviceModel>
  <services>
    <service name="MyService" behaviorConfiguration="myServiceBehavior">
    <endpoint address="http://localhost:9005/"
          binding="webHttpBinding"
          contract="IMyService"
          behaviorConfiguration="myServerEndpointBehavior"/>
    </service>
  </services>
  </system.serviceModel>
  <!-- WHERE TO ENABLE/DISABLE http keep alive and timeout -->
</configuration>

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?

Thanks, Nate.