title: WCF service authentication by SessionId
body: <p>I want to authenticate a WPF client through Session Management.
  Firstly, user with the help of a wpf form will access the WCF service and will generate a seesion ID and if user again want to access the service, instead of authenticating using username and password we would like to authenticate, using the seesion ID which was generated in the previous step.</p>
  
  <p>So kindly suggest what could be the best possible way to get a desired output?</p>
  
  <p>I am not using the web.config file. Instead I am using configuration part in C# code which is below:- </p>
  
  <pre><code>[ServiceContract(SessionMode=SessionMode.Required)] 
  public interface Iexecute { 
      [OperationContract] 
      string loginUserName(); 
  
      [OperationContract] 
      string LoginPassword(string SessionId); 
  } 
  
  [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)] 
  public class Execute : Iexecute, IDisposable
  </code></pre>
  
  <p>Another part of configuartion is :- </p>
  
  <pre><code>ServiceHost host = new ServiceHost(typeof(Execute), new Uri("net.tcp://localhost:4233"))) { host.AddServiceEndpoint(typeof(Iexecute), new NetTcpBinding(), "Execute"); 
  NetTcpBinding tcpsessionBinding = new NetTcpBinding(); tcpsessionBinding.ReliableSession.Enabled = true; tcpsessionBinding.ReliableSession.InactivityTimeout = TimeSpan.FromMinutes(25); 
  </code></pre>