为什么我不能将我的Object传递给在Webservice中创建的会话?
[WebMethod]
public void UpdatedData(string CountryName, string CountryCode,
string City, string RegionCode, string RegionName)
{
Chat ch = new Chat();
ch.CountryName = CountryName;
ch.CountryCode = CountryCode;
ch.City = City;
ch.RegionCode = RegionCode;
ch.RegionName = RegionName;
Session["Chat"] = ch; //object Refrence not set to instance of an object
}
答案 0 :(得分:3)
请在上面的方法上面加上以下代码:
[System.Web.Services.WebMethod(EnableSession=true)]
答案 1 :(得分:1)
[ WebMethod(Description="Per session Hit Counter",EnableSession=true)]
public void UpdatedData(string CountryName, string CountryCode, string City, string RegionCode, string RegionName)
{
Chat ch = new Chat();
ch.CountryName = CountryName;
ch.CountryCode = CountryCode;
ch.City = City; ch.RegionCode = RegionCode;
ch.RegionName = RegionName;
Session["Chat"] = ch;
}