HTTP Module으로이 작업을 수행 할 수 있습니다. 모듈이 확실로드되어 있는지 확인하여 web.config
에서 지금
public class SessionCatchingModule : IHttpModule //You will need to import System.Web
{
public void Init(HttpApplication context)
{
//Get the SessionstateModule and attach our own events to it
var module = context.Modules["Session"] as SessionStateModule;
if (module != null)
{
module.Start += this.Session_Start;
module.End += this.Session_end;
}
}
private void Session_Start(object sender, EventArgs args)
{
//Oh look, a session has started
}
private void Session_End(object sender, EventArgs args)
{
//Oh look, a session has ended
}
}
:
<system.webServer>
<modules>
<add name="SessionCatchingModule"
type="YourNamespace.Goes.Here., SessionCatchingModule" />
</modules>
</system.webServer>
다음은 예입니다