WCF KeepAliveEnabled to false for WS or Basic HTTP binding, What it supposed to do???

יום שני, אוגוסט 4, 2008

Hi All, There is property called KeepAliveEnabled on HttpTransportBindingElement of WS\Basic http binding. This property can be change on the WCF client configuration only in custom binding. On WS\Basic http binding you can reach the KeepAliveEnabled property only using code. Code Example: ServiceHost host; Type serviceType = typeof(MyService); host = new ServiceHost(serviceType);   ServiceEndpointCollection endpoints = host.Description.Endpoints;   foreach (ServiceEndpoint endpoint in endpoints) {      if (endpoint.Name == "wsHttpEndPoint")      {            endpoint.Binding.CreateBindingElements().Find<HttpTransportBindingElement>().KeepAliveEnabled = false;            break;      } }   The default behavior of WCF is to work with KeepAliveEnabled=true, so when WCF client proxy open connection and decide not to close it, the connection stay open because of the keep alive HTTP header (Connection=KeepAlive) that server forward to client. if I...