mirror of
https://github.com/mm201/GamestatsBase.git
synced 2026-09-07 10:06:08 -05:00
Make session expiry work on IIS 7.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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('?');
|
||||
|
||||
Reference in New Issue
Block a user