protected void Page_Load(object sender, EventArgs e) { #region 线控制 string txt = WebFramework.GeneralMethodBase.CheckStartOrEnd(); if (string.IsNullOrEmpty(txt) == false) { this.lbErr.Text = txt; } #endregion #region 系统维护开关 string WhTxt = WebFramework.GeneralMethodBase.IsCheckWH(); if (string.IsNullOrEmpty(WhTxt) == false) { this.lbErr.Text = WhTxt; return; } #endregion Model.SessionModel orderSession = WebFramework.SessionManage.SessionMethod.SessionInstance.GetSession(); string opid = orderSession.OpenId; #region 验证openid if (Common.ValidateHelper.IsOpenid(opid) == false) { WebFramework.GeneralMethodBase.WebDebugLog(opid, "openid异常:opid:" + opid); Response.Redirect("/default.aspx"); Response.End(); return; } #endregion }
override protected void OnInit(EventArgs e) { base.OnInit(e); if (WebFramework.GeneralMethodBase.IsMoblie() == false) { Response.End(); return; } orderSession = SessionMethod.SessionInstance.GetSession(); #region 检查session if (orderSession == null) { Response.Redirect("/default.aspx"); Response.End(); return; } #endregion }
/// <summary> /// 获取OpenId /// </summary> /// <param name="istest">true-返回固定OpenId false-返回获取OpenId</param> /// <param name="isbase">true-获取OpenId false-获取微信昵称</param> /// <returns></returns> public string GetOpenId(bool istest = false, bool isbase = true) { string Codes = string.IsNullOrEmpty(Request["codes"]) ? "" : Request["codes"]; if (istest) { SessionMethod.SessionInstance.SetSession("倘若", "otzXTjqt6B6xXVjozCblakccTUyw", "...", Codes); return("otzXTjqt6B6xXVjozCblakccTUyw"); } Model.SessionModel session = SessionMethod.SessionInstance.GetSession(); if (session != null && Common.ValidateHelper.IsOpenid(session.OpenId)) { if (Codes.Length > 0) { SessionMethod.SessionInstance.SetSession("", session.OpenId, "", Codes); } return(session.OpenId); } WxResultMsg baseopid = WeiXinOpenId.GetOpenId(WebFramework.GeneralMethodBase.GetHost().Replace("demo", "").ToLower(), isbase) as WxResultMsg; if (isbase && baseopid.snsapibase != null && Common.ValidateHelper.IsOpenid(baseopid.snsapibase.openid)) { SessionMethod.SessionInstance.SetSession("", baseopid.snsapibase.openid, "", Codes); return(baseopid.snsapibase.openid); } else if (isbase == false && baseopid.userinfo != null && Common.ValidateHelper.IsOpenid(baseopid.userinfo.openid)) { SessionMethod.SessionInstance.SetSession(baseopid.userinfo.nickname.Replace("'", ""), baseopid.userinfo.openid, baseopid.userinfo.headimgurl, Codes); return(baseopid.userinfo.openid); } else { HttpContext.Current.Response.End(); return(""); } }
public Model.ReturnValue CheckSession() { Model.ReturnValue result = new Model.ReturnValue(); #region 获取session orderSession = WebFramework.SessionManage.SessionMethod.SessionInstance.GetSession(); if (orderSession == null) { result.ErrMessage = "系统繁忙,请稍后再试!"; result.Success = false; return(result); } else { result.ErrMessage = ""; result.Success = true; return(result); } #endregion }