繁体   English   中英

为什么无法将我的对象传递到在Webservice中创建的会话中

[英]Why can't I pass my Object into session created in Webservice

为什么不能将我的对象传递到在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;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM