2016-03-03 3 views
0

Я пытаюсь настроить два окна Windowz (win1, win2) между лаковым балансировочным устройством.Совместное сеанс с сервером состояния сеанса

Состояние сеанса для приложения настроено как «государственный сервер», указывающий на третью машину (x.y.w.z). Вызов telnet x.y.w.z 42424 в порядке от win1 и win2. Al машины имеют одинаковую версию ОС. Обе машины имеют ту же машину ключ enter image description here

Я упал в анс странице отладки ASPX скопированы из http://pardini.net/blog/2011/02/17/the-ultimate-asp-net-session-state-debugging-tool/ и показывает два разных ключа машины.

enter image description here

я могу видеть, что AppDomainAppId отличается; как я могу его изменить? Что здесь происходит?

ответ

0

Как было предложено в Sharing session state over multiple ASP.NET applications with ASP.NET state server я добавил крюк в Global.aspx.cs

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using NHibernate; 
using NHibernate.Cfg; 
using NHibernate.Context; 
using NHibernate.Mapping.Attributes; 
using System.Web.SessionState; 
using System.Reflection; 

/// <summary> 
/// Summary description for Global 
/// </summary> 
public class Global : System.Web.HttpApplication 
{ 
    public static ISessionFactory SessionFactory; 

private static Configuration _configuration; 

public override void Init() 
{ 
    base.Init(); 
    foreach (string moduleName in this.Modules) 
    { 
     string appName = "MYAPPNAME"; 
     IHttpModule module = this.Modules[moduleName]; 
     SessionStateModule ssm = module as SessionStateModule; 
     if (ssm != null) 
     { 
      FieldInfo storeInfo = typeof(SessionStateModule).GetField("_store", BindingFlags.Instance | BindingFlags.NonPublic); 
      SessionStateStoreProviderBase store = (SessionStateStoreProviderBase)storeInfo.GetValue(ssm); 
      if (store == null) //In IIS7 Integrated mode, module.Init() is called later 
      { 
       FieldInfo runtimeInfo = typeof(HttpRuntime).GetField("_theRuntime", BindingFlags.Static | BindingFlags.NonPublic); 
       HttpRuntime theRuntime = (HttpRuntime)runtimeInfo.GetValue(null); 
       FieldInfo appNameInfo = typeof(HttpRuntime).GetField("_appDomainAppId", BindingFlags.Instance | BindingFlags.NonPublic); 
       appNameInfo.SetValue(theRuntime, appName); 
      } 
      else 
      { 
       Type storeType = store.GetType(); 
       if (storeType.Name.Equals("OutOfProcSessionStateStore")) 
       { 
        FieldInfo uribaseInfo = storeType.GetField("s_uribase", BindingFlags.Static | BindingFlags.NonPublic); 
        uribaseInfo.SetValue(storeType, appName); 
       } 
      } 
     } 
    } 
} 
(...) 
Смежные вопросы