vipul Tiwari
vipul Tiwari

Reputation: 46

how to maintain wcf service per session calling url from android studio

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.

Upvotes: 0

Views: 42

Answers (0)

Related Questions