Jquery 如何使所有html与webservice保持会话状态?

Jquery 如何使所有html与webservice保持会话状态?,jquery,web-services,Jquery,Web Services,我想在使用webservice的会话中,在我的页面中保留完整的html,但是 设置会话步骤引发此异常 对象引用未设置为对象的实例 我的职能是 [WebMethod(Description = "Gsetsession")] [ScriptMethod(UseHttpGet = false)] public void SetSession(string html) { HttpContext.Current.Session["html"] = html; } [WebMethod(Des

我想在使用webservice的会话中,在我的页面中保留完整的html,但是 设置会话步骤引发此异常

对象引用未设置为对象的实例

我的职能是

[WebMethod(Description = "Gsetsession")]
[ScriptMethod(UseHttpGet = false)]
public void SetSession(string html)
{
    HttpContext.Current.Session["html"] = html;
}

[WebMethod(Description = "GetSession")]
[ScriptMethod(UseHttpGet = false)]
public string GetSession()
{
    if (HttpContext.Current.Session["html"] != null)
    {
        return HttpContext.Current.Session["html"].ToString();
    }
    else 
    {
        return "";
    }
}

在web方法中,确保启用会话

[ WebMethod(Description="Get Session",EnableSession=true)]

可能存在的副本