BobZhu

Hi, all

As long as I know, a new Session ID can be assigned to a user for every new call into the Service.The sample code may look like this:

namespace BankServices
{

    [ServiceContract(SessionMode=SessionMode.Required)]
    public interface IAccountActivities
    {
        [OperationContract]
        decimal getBalance(string AccountNumber);

   }

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]
    public class AccountActivities : IAccountActivities
    {
        private decimal _currentBalance; 

        public decimal getBalance(string AccountNumber)
        {
            return _currentBalance;
        }
    }
}

But the point is how can I get the value of session ID. I need the exact value of session ID for further use.

Thanks for your help. Sample code is recommended.

 



Re: Windows Communication Foundation (Indigo) How can I get session ID?

Brian Rogers - MSFT

Hi Bob,

When you are in the context of a service operation, you can use the OperationContext class to get at many properties, one of which is SessionId.

Using your example above, you could do this:

public decimal getBalance(string AccountNumber)
{
Console.WriteLine("The current Session Id is {0}", OperationContext.Current.SessionId);
return _currentBalance;
}

- Brian





Re: Windows Communication Foundation (Indigo) How can I get session ID?

BobZhu

That's of great help.

Thanks a lot. Brian

-Bob