2011-11-04 111 views
1

我想在我的请求处于活动状态时使用HttpContext.Current.Items,并在其中存储散列表,直到请求结束。asp.net httpContext会话管道

我需要知道在Global.asax文件中我可以添加HttpContext.Current.items(HT)到会话中...

我在ASAX尝试了很多不同的领域,没有运气。

这是一个ASP.NET 3.5应用程序,但通话的95%与AJAX做 - 如果有差别......

感谢名单 杰里

+0

你在会议上指的是要求吗? – GregL

+0

你使用ASP.NET webforms还是ASP.NET MVC?这使差异... –

+0

使用ASP.NET webforms。 – Jerry

回答

1

怎么样PostRequestHandlerExecute事件,如这里:

public class Global : System.Web.HttpApplication 
{ 

    void Application_Start(object sender, EventArgs e) 
    { 
     HttpContext.Current.Items.Add("ht", new System.Collections.Hashtable()); 
    } 

    protected void Application_PostRequestHandlerExecute(object sender, EventArgs e) 
    { 
     HttpContext.Current.Session.Add("ht", HttpContext.Current.Items["ht"]); 
    } 
} 

这一事件应该触发,一旦你HttpHander已处理完