现象:今天遇到个bug,获取不到变量openid
原因:
- openid通过微信服务获取后,保存在Session中
- 然后在WebService中使用Session获取该变量,但没有设置 EnableSession
WebMethod 默认 EnableSession = false
解决:[WebMethod(EnableSession = true)]
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
public string Binding()
{
return Session["openid"].ToString();
}