为什么当StateProvider不INPROC不会引发Session_End中的事件吗?

问题描述:

我要问这个问题,出于好奇。

I'm asking this question out of curiosity.

我在Global.asax中注意到了这一点。

I noticed this in my global.asax

void Session_End(object sender, EventArgs e)
{
    // Code that runs when a session ends. 
    // Note: The Session_End event is raised only when the sessionstate mode
    // is set to InProc in the Web.config file. If session mode is set to StateServer 
    // or SQLServer, the event is not raised.
}

我想知道为什么Session_End中的事件则不会捕捉/引发当会话模式的StateServer或SQLServer的?

I want to understand why Session_End event is not captured/raised when the session mode is StateServer or SQLServer ?

,因为 ASP.NET会话状态它不是在内存中了...

because the ASP.NET Session State it's not in memory anymore...

使用不同的过程来存储会话状态时,在 IIS不知道会话结束时(因为它没有耦合,会话状态不会被IIS举行了)..

when using a different process to store the Session State, the IIS does not know (because it is not coupled, the session state is not held by the IIS anymore) when the session ends...

这是专门因为超时,我从来没有尝试过,但确实是事件触发,当你调用programaticaly Session.Abandon()??

this is specially because the timeouts, I never tried, but does that event fires when you programaticaly call Session.Abandon() ??