protected void Session_Start() { using (var dbContext = new EntitiesContainer()) { var repository = new SessionsRepository() {Context = dbContext}; var sessionEntry = new Session() { IpAddress = Context.Request.UserHostAddress, StartDate = DateTime.Now, ServerSessionId = Session.SessionID, UserAgent = Context.Request.UserAgent }; repository.Add(sessionEntry); repository.Commit(); } }
/// <summary> /// Create a new Session object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="userAgent">Initial value of the UserAgent property.</param> /// <param name="serverSessionId">Initial value of the ServerSessionId property.</param> /// <param name="ipAddress">Initial value of the IpAddress property.</param> /// <param name="startDate">Initial value of the StartDate property.</param> public static Session CreateSession(global::System.Int32 id, global::System.String userAgent, global::System.String serverSessionId, global::System.String ipAddress, global::System.DateTime startDate) { Session session = new Session(); session.Id = id; session.UserAgent = userAgent; session.ServerSessionId = serverSessionId; session.IpAddress = ipAddress; session.StartDate = startDate; return session; }
/// <summary> /// Deprecated Method for adding a new object to the SessionSet EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSessionSet(Session session) { base.AddObject("SessionSet", session); }