저는 Person 객체를 얻고 List를 반환하는 일반 wcf 서비스를 만들고 있습니다. 들어오는 Person 객체를 세션에 저장하고 목록을 반환해야합니다. 아래 코드를 구현했습니다.WCF 서비스의 세션 변수
[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;
}
}
하지만 항상 매개 변수로 전달 된 객체 만 있습니다. 전체 컬렉션이 아닙니다. 그래서 항상 session은 null을 반환합니다. 나는 무엇을 놓쳤는가?