public override void Init()
 {
     base.Init();
     try
     {
         // Get the app name from config file...
         string appName = ConfigurationManager.AppSettings["ApplicationName"];
         if (!string.IsNullOrEmpty(appName))
         {
             foreach (string moduleName in this.Modules)
             {
                 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);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public string ApplyAppPathModifier(string virtualPath)
        {
            if (virtualPath == null || context == null)
            {
                return(null);
            }

            if (virtualPath.Length == 0)
            {
                return(context.Request.RootVirtualDir);
            }

            if (UrlUtils.IsRelativeUrl(virtualPath))
            {
                virtualPath = UrlUtils.Combine(context.Request.RootVirtualDir, virtualPath);
            }
            else if (UrlUtils.IsRooted(virtualPath))
            {
                virtualPath = UrlUtils.Canonic(virtualPath);
            }

            bool cookieless            = false;
            SessionStateSection config = WebConfigurationManager.GetWebApplicationSection("system.web/sessionState") as SessionStateSection;

            cookieless = SessionStateModule.IsCookieLess(context, config);

            if (!cookieless)
            {
                return(virtualPath);
            }

            if (app_path_mod != null && virtualPath.IndexOf(app_path_mod) < 0)
            {
                if (UrlUtils.HasSessionId(virtualPath))
                {
                    virtualPath = UrlUtils.RemoveSessionId(VirtualPathUtility.GetDirectory(virtualPath), virtualPath);
                }
                return(UrlUtils.InsertSessionId(app_path_mod, virtualPath));
            }

            return(virtualPath);
        }
Exemplo n.º 3
0
        public override void Init()
        {
            base.Init();

            foreach (string moduleName in this.Modules)
            {
                string             appName = "APPNAME1";
                IHttpModule        module  = this.Modules[moduleName];
                SessionStateModule ssm     = module as SessionStateModule;
                if (ssm != null)
                {
                    FieldInfo storeInfo  = typeof(SessionStateModule).GetField("_store", BindingFlags.Instance | BindingFlags.NonPublic);
                    FieldInfo configMode = typeof(SessionStateModule).GetField("s_configMode", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static);

                    SessionStateMode mode = (SessionStateMode)configMode.GetValue(ssm);
                    if (mode == SessionStateMode.StateServer)
                    {
                        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);
                                object obj = null;
                                uribaseInfo.GetValue(obj);
                            }
                        }
                    }
                    break;
                }
            }
        }
Exemplo n.º 4
0
        public void Init(HttpApplication app)
        {
            lock (_lock)
            {
                //if (_instanceCount == 0)
                //{
                //}

                _instanceCount++;
            }

            _app = app;

            _app.EndRequest += new EventHandler(Context_EndRequest);

            SessionStateModule sessionModule = _app.Modules["Session"] as SessionStateModule;

            if (sessionModule != null)
            {
                sessionModule.End += new EventHandler(Session_End);
            }
        }
Exemplo n.º 5
0
        void Execute(string path, TextWriter writer, bool preserveForm, bool isTransfer)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            if (path.IndexOf(':') != -1)
            {
                throw new ArgumentException("Invalid path.");
            }

            string queryString = null;
            int    qmark       = path.IndexOf('?');

            if (qmark != -1)
            {
                queryString = path.Substring(qmark + 1);
                path        = path.Substring(0, qmark);
            }

            string exePath    = UrlUtils.Combine(context.Request.BaseVirtualDir, path);
            bool   cookieless = false;

#if NET_2_0
            SessionStateSection config = WebConfigurationManager.GetWebApplicationSection("system.web/sessionState") as SessionStateSection;
            cookieless = SessionStateModule.IsCookieLess(context, config);
#else
            SessionConfig config = HttpContext.GetAppConfig("system.web/sessionState") as SessionConfig;
            cookieless = config.CookieLess;
#endif
            if (cookieless)
            {
                exePath = UrlUtils.RemoveSessionId(VirtualPathUtility.GetDirectory(exePath), exePath);
            }

            IHttpHandler handler = context.ApplicationInstance.GetHandler(context, exePath, true);
            Execute(handler, writer, preserveForm, exePath, queryString, isTransfer, true);
        }
Exemplo n.º 6
0
 public void FixtureSetUp()
 {
     app    = new HttpApplication();
     module = new SessionStateModule();
 }
Exemplo n.º 7
0
        private void SetReadOnly(SessionStateModule module)
        {
            FieldInfo readOnly = module.GetType().GetField("_rqReadonly", BindingFlags.Instance | BindingFlags.NonPublic);

            readOnly.SetValue(module, true);
        }
Exemplo n.º 8
0
        private SessionStateStoreProviderBase GetProvider(SessionStateModule module)
        {
            FieldInfo store = module.GetType().GetField("_store", BindingFlags.Instance | BindingFlags.NonPublic);

            return((SessionStateStoreProviderBase)store.GetValue(module));
        }
Exemplo n.º 9
0
        private bool GetStateNotFound(SessionStateModule module)
        {
            FieldInfo stateNotFound = module.GetType().GetField("_rqSessionStateNotFound", BindingFlags.Instance | BindingFlags.NonPublic);

            return((bool)stateNotFound.GetValue(module));
        }
Exemplo n.º 10
0
        private SessionStateStoreData GetStoreData(SessionStateModule module)
        {
            FieldInfo item = module.GetType().GetField("_rqItem", BindingFlags.Instance | BindingFlags.NonPublic);

            return((SessionStateStoreData)item.GetValue(module));
        }
Exemplo n.º 11
0
        private object GetLockId(SessionStateModule module)
        {
            FieldInfo lockId = module.GetType().GetField("_rqLockId", BindingFlags.Instance | BindingFlags.NonPublic);

            return(lockId.GetValue(module));
        }
Exemplo n.º 12
0
 internal void AddDelayedHttpSessionState(SessionStateModule module);