0

我有一個用asp.net mvc2編寫的web應用程序。目前託管在亞馬遜雲ec2上。由於流量不斷增加,我們希望移動多實例環境。我有一個自定義會話類,當前在會話開始時啓動(全局asax),我通過應用程序中的getter或setter類使用。由於多實例家務,我必須處理漏洞安全架構。我正在尋找更好的方法來處理這個問題。亞馬遜ec2上的ASP.NET MVC多實例會話管理

protected void OnSessionStart() 
    { 
     HttpContext.Current.Session.Add("mySessionObject", new MyAppSession()); 
    } 


    public static MyAppSession GetMySessionObject(HttpContextBase current) 
    { 
     if (current != null) 
     { 
      if (current.Session != null) 
       if (current.Session["mySessionObject"] == null) 
       { 
        current.Session.Add("mySessionObject", new MyAppSession()); 
       } 
     } 
     if (current != null && current.Session != null) 
      return (MyAppSession) (current.Session["mySessionObject"]); 
     return null; 
    } 


and so on. 

回答

0

在多實例環境中有多種會話管理選項。

會話狀態數據庫
如果我們希望每個請求進行親那麼我們 保持在數據庫會話信息和 之間傳遞信息他們。這很難實現。

棒用戶會話
有了這個你不必來實現自定義 會話管理。您可以粘貼一個用戶,並根據 實例而不是每個請求進行關聯。

我選擇第二個。