A second answer dealing with custom SessionStateStores. On looking at the code I could see no reason why it wouldn't call session start so I tried to create my own compliant but non-functional session state provider to see what was going on. With my session state provider it called the Session_start in global.asax fine. I include my code as a demo proof of concept:
Session State Provider:
namespace WebApplication1
{
public class SessionStateProvider : System.Web.SessionState.SessionStateStoreProviderBase
{
public override SessionStateStoreData CreateNewStoreData(HttpContext context, int timeout)
{
ISessionStateItemCollection foo = new SessionStateItemCollection();
HttpStaticObjectsCollection bar = new HttpStaticObjectsCollection();
return new SessionStateStoreData(foo, bar, 300);
}
public override void CreateUninitializedItem(HttpContext context, string id, int timeout){}
public override void Dispose() { }
public override void EndRequest(HttpContext context) { }
public override SessionStateStoreData GetItem(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actions)
{
locked = false;
lockAge = TimeSpan.FromSeconds(10);
lockId = new object();
actions = SessionStateActions.None;
ISessionStateItemCollection foo = new SessionStateItemCollection();
HttpStaticObjectsCollection bar = new HttpStaticObjectsCollection();
return new SessionStateStoreData(foo, bar, 300);
}
public override SessionStateStoreData GetItemExclusive(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actions)
{
locked = false;
lockAge = TimeSpan.FromSeconds(10);
lockId = new object();
actions = SessionStateActions.None;
ISessionStateItemCollection foo = new SessionStateItemCollection();
HttpStaticObjectsCollection bar = new HttpStaticObjectsCollection();
return new SessionStateStoreData(foo, bar, 300);
}
internal virtual void Initialize(string name, NameValueCollection config, IPartitionResolver partitionResolver) { }
public override void InitializeRequest(HttpContext context) { }
public override void ReleaseItemExclusive(HttpContext context, string id, object lockId) { }
public override void RemoveItem(HttpContext context, string id, object lockId, SessionStateStoreData item) { }
public override void ResetItemTimeout(HttpContext context, string id) { }
public override void SetAndReleaseItemExclusive(HttpContext context, string id, SessionStateStoreData item, object lockId, bool newItem) { }
public override bool SetItemExpireCallback(SessionStateItemExpireCallback expireCallback){return true;}
}
}
Global.asax:
protected void Session_Start(object sender, EventArgs e)
{
throw new Exception("It worked!");
}
web.config:
<sessionState mode="Custom" customProvider="MySessionProvider">
<providers>
<add name="MySessionProvider" type="WebApplication1.SessionStateProvider"/>
</providers>
</sessionState>
The point of this post is mainly to say that if you are using the provided session management module, even with a custom provider it should still fire off the session_start event. Perhaps you can try with my dummy state provider and see if that fires off your event. Also I assume that the signature of your session_onstart is actually correct? (ie no paramaters or (object,eventargs) ).
Currently we are at a duff position because all the information we have so far is along the wrong lines. We are now left with either something about your sessionstateprovider is causing the session_start not to fire or something about the rest of your code is. Using my dummy should help us answer that question (I hope).
For what its worth the session_start event should get fired just after the CreateNewStoreData
method has run in your provider class so you can try putting in a breakpoint there and just seeing where it does head to after that method.