2012-10-03 123 views
1

在MVC Global.asax文件中,我們可以看到Application_Start此事件只觸發一次。但會議尚未活動/可在這裏。所以我的問題是,是否有Global.asax文件中的任何事件觸發一次,會話也可用?
我之所以問這個是因爲,我用ExpandoObject
如:Global.asax文件中只觸發一次的事件

public static dynamic Data 
    { 
     get 
     { 
      #region FAILSAFE 
      if (HttpContext.Current.Session[datakey] == null) 
      { 
       HttpContext.Current.Session[datakey] = new ExpandoObject(); 
      } 
      #endregion 

      return (ExpandoObject)HttpContext.Current.Session[datakey]; 
     } 
    } 

我想用空的值在初始化一次我所有的ExpandoObject的:

MyExpando.Data.UserInformation = null; 
MyExpando.Data.FolderInformation = null; 

這就是爲什麼我正在尋找一次只發射一次的事件。

回答

3
protected void Session_Start(object sender, EventArgs e) 
{ 
    // Will fire once when a new user session is created. 

    // Contrary to Application_Start this event could run multiple 
    // times during the AppDomain lifetime but that will ensure you 
    // that all users have the required data stored into the session. 
} 
0

它的會話開始事件您正在尋找..