public DataResult LoginDefault(string code) { try { var userInfo = Asp.GetSession("OAuthUserInfo") as OAuthUserInfo; if (userInfo == null) { if (!code.IsNullOrEmpty()) { var oauthResult = OAuthApi.GetAccessToken(WechatHelper.AppID, WechatHelper.AppSecret, code); userInfo = OAuthApi.GetUserInfo(oauthResult.access_token, oauthResult.openid); Asp.SetSession("OAuthUserInfo", userInfo);//userToken只能使用一次 获取用户信息记录到session if (LoginMobileByOpenId(userInfo.openid)) { return(new DataResult("true", "登录成功", "WeChatScan.aspx", null)); } } else { return(new DataResult("false", "未绑定微信号", "Login.aspx", null)); } } else { if (LoginMobileByOpenId(userInfo.openid)) { return(new DataResult("true", "登录成功", "WeChatScan.aspx", null)); } } } catch (Exception e) { Logger.LogToDb(e.Message); } return(new DataResult("false", "未绑定微信号", "Login.aspx", null)); }
public static string TestSession(string info) { Asp.SetSession("info", info); return(Asp.GetSession <string>("info")); }