I am just creating a normal wcf service which get the Person object and returns the List. I need to save incoming Person object in a session and returns the list. I have implemented the code like below
[AspNetCompatibilityRequirements(RequirementsMode= AspNetCompatibilityRequirementsMode.Required)]
public class Service1 : IService1
{
public List<Person> getPerson(Person person)
{
List<Person> persons;
if (HttpContext.Current.Session["personList"] != null)
{
persons = (List<Person>)HttpContext.Current.Session["personList"];
}
else
{
persons = new List<Person>();
}
persons.Add(person);
HttpContext.Current.Session["personList"] = persons;
return persons;
}
}
But always i got only the object i passed in the parameter. Not the entire collection. So always session is returns null. What i missed?