.NET WebService中使用 Session

现象

今天遇到个BUG,获取不到opendid

原因

在WebService中使用Session获取变量,没有设置 EnableSession

WebMethod 默认 EnableSession = false

解决

[WebMethod(EnableSession = true)]

[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
public string Binding()
{
  return Session["sessionKey"].ToString();
}
原文地址:https://www.cnblogs.com/yanjiez/p/10065046.html