【问题标题】:How can I keep all html in session with webservice?如何让所有 html 与 web 服务保持会话?
【发布时间】:2015-05-19 02:36:07
【问题描述】:

我想在使用 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 "";
    }
}

【问题讨论】:

标签: jquery web-services


【解决方案1】:

在您的网络方法中,确保启用会话

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

Reference

【讨论】:

    猜你喜欢
    • 2010-12-29
    • 2011-12-19
    • 1970-01-01
    • 2012-10-15
    • 1970-01-01
    • 1970-01-01
    • 2015-08-04
    • 1970-01-01
    • 2013-07-17
    相关资源
    最近更新 更多