PersistSessionState() static private method

Tracks information about the session so rollbacks can be handled cleanly across app domain restarts
static private PersistSessionState ( ) : void
return void
Beispiel #1
0
            protected override void OnExecute(HttpContext ctx)
            {
                using (Session.Tracker.Exclusive(WebServerLockTimeoutMS, Response.Log))
                {
                    Session.AsyncLog.CopyInto(Response.AsyncLog);
                    Session.AsyncLog = new SerializableLog();

                    if (Session.IsActive)
                    {
                        Response.Log.Write("Ending the active session ({0})", Session.ID);
                        EndSession(Response.Log);
                        Response.Log.Write("Session has been ended");
                    }
                    else if (Session.IsRollbackPending)
                    {
                        // handle unexpected app domain restarts where there's no active session but a rollback is still expected
                        Session.IsRollbackPending = false;
                        Response.Log.Write("Cleaned up session after unexpected app domain restart");
                    }
                    else
                    {
                        Response.Log.Write("There is no active session to end");
                    }

                    Module.PersistSessionState();
                }
            }
Beispiel #2
0
            protected override void OnExecute(HttpContext ctx)
            {
                Module.EnsureRegistered();

                // Wait for all currently executing ASP requests to complete so we're in a clean state
                // before messing around with transactions.  Being extra careful here
                // should also prevent bleed over from any prior sessions into this one.
                using (Session.Tracker.Exclusive(WebServerLockTimeoutMS, Response.Log))
                {
                    Session.AsyncLog.CopyInto(Response.AsyncLog);
                    Session.AsyncLog = new SerializableLog();

                    // If there is currently an open session, end it before starting a new one
                    if (Session.IsActive)
                    {
                        Response.Log.Write("Ending prior session ({0})", Session.ID);
                        EndSessionRequest.EndSession(Response.Log);
                    }

                    sessionId           = Session.ID = Guid.NewGuid();
                    Session.Transaction = Transaction;
                    Response.Log.Write("Session started ({0})", sessionId);
                    Session.AsyncLog = new SerializableLog();

                    Module.PersistSessionState();

                    // Watch for when the transaction ends unexpectedly so some cleanup can occur.
                    // This event handler will run on the thread that is causing the rollback which is likely a
                    // different thread than is registering the event handler.
                    Transaction.TransactionCompleted += Transaction_TransactionCompleted;
                }
            }