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

.NET WebService中使用 Session

 

现象

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

原因

WebMethod 默认 EnableSession = false

解决

[WebMethod(EnableSession = true)]

复制代码
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
public string Binding()
{
  return Session["sessionKey"].ToString();
}
复制代码
 
posted on 2022-03-24 09:34  HackerVirus  阅读(89)  评论(0)    收藏  举报