0

I created WCF service and calling it from the android studio and its working fine, but after implementing WCF perSession functionality it is working for a single user at a time. Problem: My problem is when i am hitting WCF url with multiple user my sessionID get overwrite by the latest logged in user, So how to maintain session for multiple user like we do in web application. I used this to creste session in WCF:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]

and this is my method to create sessionid within services class

public class MyService : IMyService
{
  static string currentSessionID = string.Empty;

    public string createSession()
    {
        currentSessionID = DateTime.Now.Ticks.ToString();
        return currentSessionID;
    }
    public string Login()
    {
        var mysessionId = createSession();
        return mysessionId;
    }
    public string Mymethods(string data)
    {
        string response = "";
        if(data.StartsWith("01"))
           response = Login();
        return response;
    }
}

and am hitting this createSession() method only in login function.

Please help me out of this..... Thanks in advnance.

Manoj Choudhari
  • 5,277
  • 2
  • 26
  • 37
  • 1
    You will need a more advanced method of storing sessions. I'm thinking that you should be able to find a library that does this already - perhaps even an official one. – fredrik Oct 14 '19 at 07:42
  • please help me with some links, coz I didn't find any, and my wcf service is created in visual studio 2010 version. – vipul Tiwari Oct 14 '19 at 07:50

0 Answers0