kevin-Y

在Global.asax、HttpModule中使用Session

经测试,可以在AcquireRequestState、PreRequestHandlerExecute事件中处理Session
Global.asax部分代码
void Application_AcquireRequestState(object sender, EventArgs e)
    
{
        
string str = HttpContext.Current.Session.SessionID;
    }


    
void Application_PreRequestHandlerExecute(object sender, EventArgs e)
    
{
        
string str = HttpContext.Current.Session.SessionID;
    }

一个实现IHttpModule的类的部分代码
public void Init(HttpApplication context)
{
    context.AcquireRequestState 
+= new EventHandler(context_AcquireRequestState);
    context.PreRequestHandlerExecute 
+= new EventHandler(context_PreRequestHandlerExecute);
}


void context_PreRequestHandlerExecute(object sender, EventArgs e)
{
    
string str = HttpContext.Current.Session.SessionID;
}


void context_AcquireRequestState(object sender, EventArgs e)
{
    
string str = HttpContext.Current.Session.SessionID;
}

posted on 2008-05-31 09:00 生命体验之kevin-Y 阅读(926) 评论(1) 编辑 收藏

导航

统计信息

News