Why can't I pass my Object into session created in 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
}
请在上面的方法上方放置以下代码:
[System.Web.Services.WebMethod(EnableSession=true)]
[ 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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.