Example #1
0
 /// <summary>
 /// 初始化的时候
 /// </summary>
 /// <param name="requestContext"></param>
 protected override void Initialize(RequestContext requestContext)
 {
     //ajax提交上来的请求
     if (requestContext.HttpContext.Request.IsAjaxRequest() && requestContext.HttpContext.Request.RequestType.ToLower() == "post")
     {
         //封装一下ajax的数据
         RequestParameters = ParameterLoader.LoadAjaxPostParameters(requestContext.HttpContext.Request.InputStream);
     }
     base.Initialize(requestContext);
 }
Example #2
0
        /// <summary>
        /// 处理前
        /// </summary>
        /// <param name="requestContext"></param>
        protected override void Initialize(RequestContext requestContext)
        {
            try
            {
                if (requestContext.HttpContext.Request.IsAjaxRequest() && requestContext.HttpContext.Request.RequestType.ToLower() == "post")
                {
                    //预备给脚本端的数据获取接口
                    RequestParameters = ParameterLoader.LoadAjaxPostParameters(requestContext.HttpContext.Request.InputStream);
                }
                else
                {
                    //直接post的加密接口
                    //RequestParameters = ParameterLoader.LoadSecurityParameters(requestContext.HttpContext.Request.InputStream);
                    RequestParameters = ParameterLoader.LoadAjaxPostParameters(requestContext.HttpContext.Request.InputStream);
                    if (!string.IsNullOrEmpty(RequestParameters.identity) && !string.IsNullOrWhiteSpace(RequestParameters.identity))
                    {
                        //保存在Session中
                        SessionInfo session = (SessionInfo)requestContext.HttpContext.Session[SessionInfo.APISESSION_NAME];

                        //session里面没有
                        if (session != null && session.SessionUser != null && session.SessionUser.User != null)
                        {
                            //如果传入token不一致,以客户端为准
                            if (session.SessionUser.User.ID.ToString() != RequestParameters.identity)
                            {
                                var login = DIEntity.GetInstance().GetImpl <ILogin>();
                                session.SessionUser.User = login.GetAppLoginInfo(RequestParameters.identity);
                                requestContext.HttpContext.Session[SessionInfo.APISESSION_NAME] = session;
                            }
                            else
                            {
                                SessionUser = session.SessionUser.User;
                            }
                        }
                        else
                        {
                            var         login = DIEntity.GetInstance().GetImpl <ILogin>();
                            SessionInfo info  = new SessionInfo();
                            info.SessionUser.User = login.GetAppLoginInfo(RequestParameters.identity);
                            requestContext.HttpContext.Session[SessionInfo.APISESSION_NAME] = info;
                            SessionUser = info.SessionUser.User;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                SystemLog.Logs.GetLog().WriteErrorLog(e);
            }
            base.Initialize(requestContext);
        }