diff --git a/GamestatsBase/GamestatsSessionManager.cs b/GamestatsBase/GamestatsSessionManager.cs index 3a4101e..4217161 100644 --- a/GamestatsBase/GamestatsSessionManager.cs +++ b/GamestatsBase/GamestatsSessionManager.cs @@ -5,8 +5,10 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Web; +using System.Web.Caching; namespace GamestatsBase { @@ -18,7 +20,6 @@ namespace GamestatsBase public GamestatsSessionManager(HttpApplication application) { m_application = application; - m_application.EndRequest += Application_EndRequest; } private HttpApplication m_application; @@ -42,12 +43,6 @@ namespace GamestatsBase } } - private void Application_EndRequest(object sender, EventArgs e) - { - // todo: run this less often. Should be a background task like GC - PruneSessions(); - } - public void Add(GamestatsSession session) { Sessions.Add(session.Hash, session); diff --git a/Sample/Global.asax.cs b/Sample/Global.asax.cs index f7c156e..c51bba9 100644 --- a/Sample/Global.asax.cs +++ b/Sample/Global.asax.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Web; using System.Web.Security; using System.Web.SessionState; +using GamestatsBase; namespace Sample { @@ -28,6 +29,15 @@ namespace Sample } } + void Application_EndRequest(object sender, EventArgs e) + { + // todo: find a way to make session expiry happen entirely in the + // GamestatsBase library. + // Currently, I run into a problem binding the EndRequest event: + // http://stackoverflow.com/questions/2781346/why-can-event-handlers-only-be-bound-to-httpapplication-events-during-ihttpmodul + GamestatsSessionManager.FromContext(Context).PruneSessions(); + } + public static String RewriteUrl(String url, out String pathInfo, out String query) { int q = url.IndexOf('?');