Make session expiry work on IIS 7.

This commit is contained in:
Greg Edwards
2015-01-25 18:35:00 -05:00
parent 4c971789f6
commit 5ce76b7d0d
2 changed files with 12 additions and 7 deletions

View File

@@ -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);

View File

@@ -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('?');