public CheckSessionAttribute(string controller, string action, string key, CheckSession checkSession = CheckSession.Redirect) { Controller = controller.RemoveController(); Action = action; Key = key; CheckSession = checkSession; }
public CheckSessionAttribute(string key, CheckSession checkSession) : this(string.Empty, string.Empty, key, checkSession) { if (checkSession == CheckSession.Redirect) { throw new ArgumentException("checkSession", "Must specify constructor with redirect arguments for redirect on CheckSession"); } }
protected void initialPageAccess() { Configuration config = new Configuration(); conn = config.getConnectionString(); connect = new SqlConnection(conn); getSession(); //Get from and to pages: string current_page = "", previous_page = ""; if (HttpContext.Current.Request.Url.AbsoluteUri != null) { current_page = HttpContext.Current.Request.Url.AbsoluteUri; } if (Request.UrlReferrer != null) { previous_page = Request.UrlReferrer.ToString(); } //Get current time: DateTime currentTime = DateTime.Now; //Get user's IP: string userIP = GetIPAddress(); CheckSession session = new CheckSession(); bool correctSession = session.sessionIsCorrect(username, roleId, token, current_page, previous_page, currentTime, userIP); if (!correctSession) { clearSession(); } int int_roleId = Convert.ToInt32(roleId); if (int_roleId != 1)//1 = Admin role. { clearSession(); } if (session.adminAlerts() == 0) { lblError.Visible = true; lblError.Text = "There are no new alerts!"; } else { lblError.Visible = false; } }
internal static async Task <CheckIsOKResult> checkIsOK(CheckSession checkSession, State s) { // try { var playerCheck = Newtonsoft.Json.JsonConvert.DeserializeObject <PlayerCheck>(checkSession.session); playerCheck.c = "PlayerCheck"; playerCheck.FromUrl = $"{ConnectInfo.HostIP}:{ConnectInfo.tcpServerPort}";//ConnectInfo.ConnectedInfo + "/notify"; // pl playerCheck.WebSocketID = s.WebsocketID; if (Room.CheckSign(playerCheck)) { var sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(playerCheck); var reqResult = await Startup.sendInmationToUrlAndGetRes(Room.roomUrls[playerCheck.RoomIndex], sendMsg); if (reqResult.ToLower() == "ok") { s.roomIndex = playerCheck.RoomIndex; return(new CheckIsOKResult() { CheckOK = true, roomIndex = playerCheck.RoomIndex, Key = playerCheck.Key }); } } return(new CheckIsOKResult() { CheckOK = false, roomIndex = -1, Key = "不存在" }); } catch { return(new CheckIsOKResult() { CheckOK = false, roomIndex = -1, Key = "不存在" }); } }
protected void Page_Load(object sender, EventArgs e) { getSession(); if (!IsPostBack) { CheckSession session = new CheckSession(); bool correctSession = session.sessionIsCorrect(username, roleId, token); if (!correctSession) { clearSession(); } if (Request.UrlReferrer != null) { previousPage = Request.UrlReferrer.ToString(); } else { previousPage = "Home.aspx"; } } }
protected void initialPageAccess() { Configuration config = new Configuration(); conn = config.getConnectionString(); connect = new SqlConnection(conn); getSession(); //Get from and to pages: string current_page = "", previous_page = ""; if (HttpContext.Current.Request.Url.AbsoluteUri != null) { current_page = HttpContext.Current.Request.Url.AbsoluteUri; } if (Request.UrlReferrer != null) { previous_page = Request.UrlReferrer.ToString(); } previousPage = previous_page; //Get current time: DateTime currentTime = DateTime.Now; //Get user's IP: string userIP = GetIPAddress(); CheckSession session = new CheckSession(); bool correctSession = session.sessionIsCorrect(username, roleId, token, current_page, previous_page, currentTime, userIP); if (!correctSession) { clearSession(); } int int_roleId = Convert.ToInt32(roleId); if (int_roleId != 3) { clearSession(); } }