I\'m coding an authentication service that have multiple methods.one of this method is ChangePassword. I want when any body wants to change the password, logon to system bef
In order to have SessionId, you have to have Session-enabled binding. For example, wsHttpBinding. In your config file, you should have something like:
In the IMyService interface, you have to have SessionMode attribute set to Required, like so:
[ServiceContract(SessionMode = SessionMode.Required)]
public interface IMyService
{
[OperationContract]
AuthenticationData Authenticate(string username, string password);
}
When all of this is setup, you can get to the SessionId like this:
var sessionId = OperationContext.Current.SessionId;
Another way would be to enable AspNetCompatibilityRequirements but it's a bit of an overkill just to get the SessionId.