public static SessionProviderSettings GetSettings()
 {
     if (_sessionProviderSettings == null) {
         _sessionProviderSettings = ConfigurationManager.GetSection("SessionProviderSettings") as SessionProviderSettings;
     }
     return _sessionProviderSettings;
 }
 public static SessionProviderSettings GetSettings()
 {
     if (_sessionProviderSettings == null)
     {
         _sessionProviderSettings = ConfigurationManager.GetSection("SessionProviderSettings") as SessionProviderSettings;
     }
     return(_sessionProviderSettings);
 }
        void initData() {
            _providerSettings = SessionProviderSettings.GetSettings();

            var url = new MongoUrl(ConfigurationManager.ConnectionStrings["SessionDB"].ConnectionString);
            var client = new MongoClient(url);
            var database = client.GetServer().GetDatabase(url.DatabaseName);
            collection = database.GetCollection<MongoDBSessionDo>(_providerSettings.SessionProfix, WriteConcern.Unacknowledged);

            System.Configuration.Configuration cfg = WebConfigurationManager.OpenWebConfiguration(HostingEnvironment.ApplicationVirtualPath);
            sessionStateSection = (SessionStateSection)cfg.GetSection("system.web/sessionState");
        }
        void initData()
        {
            _providerSettings = SessionProviderSettings.GetSettings();

            var url      = new MongoUrl(ConfigurationManager.ConnectionStrings["SessionDB"].ConnectionString);
            var client   = new MongoClient(url);
            var database = client.GetServer().GetDatabase(url.DatabaseName);

            collection = database.GetCollection <MongoDBSessionDo>(_providerSettings.SessionProfix, WriteConcern.Unacknowledged);

            System.Configuration.Configuration cfg = WebConfigurationManager.OpenWebConfiguration(HostingEnvironment.ApplicationVirtualPath);
            sessionStateSection = (SessionStateSection)cfg.GetSection("system.web/sessionState");
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 创建Session状态存储行为实例
 /// </summary>
 /// <returns></returns>
 public static ISessionStateStoreBehavior CreateSessionStateStoreBehaviorInstance()
 {
     if (sessionStateStoreBehavior == null)
     {
         var types       = Assembly.GetExecutingAssembly().GetTypes().Where(t => !t.IsAbstract && t.GetInterface(typeof(ISessionStateStoreBehavior).Name) != null);
         var currentType = types.FirstOrDefault(t => t.Name == String.Format("{0}SessionStateBehavior", SessionProviderSettings.GetSettings().SessionStateBehavior));
         if (currentType != null)
         {
             sessionStateStoreBehavior = (ISessionStateStoreBehavior)Activator.CreateInstance(currentType);
         }
     }
     return(sessionStateStoreBehavior);
 }
Ejemplo n.º 6
0
 public override string CreateSessionID(System.Web.HttpContext context)
 {
     return(String.Format("{0}.{1}", SessionProviderSettings.GetSettings().SessionProfix, base.CreateSessionID(context)));
 }