2011-11-04 113 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已處理完