| | |
| | | /// <param name="actionContext"></param> |
| | | public override void OnActionExecuting(HttpActionContext actionContext) |
| | | { |
| | | User loginUser = JsonConvert.DeserializeObject<User>(HttpContext.Current.Session["User"].ToString()); |
| | | try |
| | | { |
| | | var User = HttpContext.Current.Session["User"].ToString(); |
| | | User loginUser = JsonConvert.DeserializeObject<User>(User); |
| | | base.OnActionExecuting(actionContext); |
| | | //如果存在 |
| | | if (redis.Get<User>("LoginUserID" + loginUser.userid, 0).userid.ToString() != "") |
| | |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "账户已过期,请重新登录2!"; |
| | | mes.Message = "登录已超时,请重新登录!"; |
| | | actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.Ambiguous, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") }; |
| | | } |
| | | } |
| | | else //如果redis登录用户中不存在当前用户 |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "账户已过期,请重新登录1!"; |
| | | mes.Message = "登录已超时,请重新登录!"; |
| | | actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.Ambiguous, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") }; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "登录已超时,请重新登录!"; |
| | | actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.Ambiguous, Content = new StringContent(JsonConvert.SerializeObject(mes), Encoding.GetEncoding("UTF-8"), "application/json") }; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |