public virtual void UnitOfWorkApplication_BeginRequest(object sender, EventArgs e) { if (IoC.IsInitialized == false) { InitializeContainer(this); } bool loadedConversation = false; if (IsAspSessionAvailable) { loadedConversation = LongConversationManager.LoadConversation(); } if (!loadedConversation) { UnitOfWork.Start(); } }
public virtual void UnitOfWorkApplication_EndRequest(object sender, EventArgs e) { if (HttpContext.Current.Server.GetLastError() == null && UnitOfWork.InLongConversation) { UnitOfWork.CurrentSession.Disconnect(); if (!IsAspSessionAvailable) { throw new InvalidOperationException( "Session must be enabled when using Long Conversations! If you are using web services, make sure to use [WebMethod(EnabledSession=true)]"); } LongConversationManager.SaveConversation(); } else { if (UnitOfWork.IsStarted) { UnitOfWork.Current.Dispose(); } } }