Home > DeveloperSection > Forums > Call dynamic webservice with session
Jayden Bell
Jayden Bell

Total Post:105

Points:739
Posted on    August-22-2014 1:35 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 592  View(s)
Rate this:

I have webservice, provide to user. User must login to use it. My problem is when user login through WSLogin on webservice, I want to save session to check for a next time.

[WebMethod(EnableSession = true)]

public string WSLogin(string username, string password)

{

    // do something

    string sID = Guid.NewGuid().ToString();

    Session.Add("SID", sID); // save session

    return sID; // return to user to check next time

}

[WebMethod(EnableSession = true)]

public string CallSomethingService(string sID)

{

    string curSID = Session["SID"].ToString() // error, Object reference not set to an instance of an object.

    // do some thing

}

I call webservice dynamically. Thank for all help



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    August-22-2014 2:03 AM

Hi Jayden, 

Instead of this:

Session.Add("SID", sID);

use this:

HttpContext.Current.Session["SID"] = sSid;


Don't want to miss updates? Please click the below button!

Follow MindStick