CALL DYNAMIC WEBSERVICE WITH SESSION

Jayden Bell

Total Post:110

Points:774
Posted by  Jayden Bell
 791  View(s)
Ratings:
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

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: Call dynamic webservice with session

    Hi Jayden, 


    Instead of this:

    Session.Add("SID", sID);

    use this:

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!