internal HttpModuleCollection CreateModules()
 {
     HttpModuleCollection modules = new HttpModuleCollection();
     foreach (HttpModuleAction action in this.Modules)
     {
         modules.AddModule(action.Entry.ModuleName, action.Entry.Create());
     }
     modules.AddModule("DefaultAuthentication", DefaultAuthenticationModule.CreateDefaultAuthenticationModuleWithAssert());
     return modules;
 }
        internal void DisposeInternal() {
            PerfCounters.DecrementCounter(AppPerfCounter.PIPELINES);

            // call derived class

            try {
                Dispose();
            }
            catch (Exception e) {
                RecordError(e);
            }

            // dispose modules

            if (_moduleCollection != null) {
                int numModules = _moduleCollection.Count;

                for (int i = 0; i < numModules; i++) {
                    try {
                        // set the init key during Dispose for modules
                        // that try to unregister events
                        if (HttpRuntime.UseIntegratedPipeline) {
                            _currentModuleCollectionKey = _moduleCollection.GetKey(i);
                        }
                        _moduleCollection[i].Dispose();
                    }
                    catch {
                    }
                }

                _moduleCollection = null;
            }
        }
 public void AddModuleToCollection(HttpModuleCollection target, string name, IHttpModule m)
 {
     CommonReflectionUtil.MakeDelegate<Action<string, IHttpModule>>(target, this._mi_HttpModuleCollection_AddModule)(name, m);
 }
		internal void Cleanup ()
		{
			try {
				Dispose ();
			} catch (Exception obj) {
				HandleError (obj);
			}

			if (null != _ModuleCollection) {
				int pos;
				int count = _ModuleCollection.Count;

				for (pos = 0; pos != count; pos++)
					((IHttpModule) _ModuleCollection.Get (pos)).Dispose ();

				_ModuleCollection = null;
			}

			_state = null;
		}
		internal void InitModules ()
		{
			ModulesConfiguration modules;

			modules = (ModulesConfiguration) HttpContext.GetAppConfig ("system.web/httpModules");
			if (null == modules)
				throw new HttpException (
						HttpRuntime.FormatResourceString ("missing_modules_config"));

			_ModuleCollection = modules.CreateCollection ();
			if (_ModuleCollection == null)
				return;

			int pos, count;

			count = _ModuleCollection.Count;
			for (pos = 0; pos != count; pos++)
				((IHttpModule) _ModuleCollection.Get (pos)).Init (this);
		}
 private void InitModules()
 {
     this._moduleCollection = RuntimeConfig.GetAppConfig().HttpModules.CreateModules();
     this.InitModulesCommon();
 }
        HttpModuleCollection BuildIntegratedModuleCollection(List<ModuleConfigurationInfo> moduleList) {
            HttpModuleCollection modules = new HttpModuleCollection();

            foreach(ModuleConfigurationInfo mod in moduleList) {
#if DBG
                Debug.Trace("NativeConfig", "Runtime module: " + mod.Name + " of type " + mod.Type + "\n");
#endif
                ModulesEntry currentModule = new ModulesEntry(mod.Name, mod.Type, "type", null);

                modules.AddModule(currentModule.ModuleName, currentModule.Create());
            }

            return modules;
        }
        // instantiates modules that have been added to the dynamic registry (classic pipeline)
        private HttpModuleCollection CreateDynamicModules() {
            HttpModuleCollection moduleCollection = new HttpModuleCollection();

            foreach (DynamicModuleRegistryEntry entry in _dynamicModuleRegistry.LockAndFetchList()) {
                HttpModuleAction modAction = new HttpModuleAction(entry.Name, entry.Type);
                moduleCollection.AddModule(modAction.Entry.ModuleName, modAction.Entry.Create());
            }

            return moduleCollection;
        }
		internal void InitOnce (bool full_init)
		{
			lock (this) {
				if (modcoll != null)
					return;

#if NET_2_0
				HttpModulesSection modules;
				modules = (HttpModulesSection) WebConfigurationManager.GetSection ("system.web/httpModules");
#else
				ModulesConfiguration modules;

				modules = (ModulesConfiguration) HttpContext.GetAppConfig ("system.web/httpModules");
#endif

				modcoll = modules.LoadModules (this);

				if (full_init)
					HttpApplicationFactory.AttachEvents (this);

#if NET_2_0
				GlobalizationSection cfg;
				cfg = (GlobalizationSection) WebConfigurationManager.GetSection ("system.web/globalization");
				app_culture = cfg.GetCulture();
				appui_culture = cfg.GetUICulture();
#else
				GlobalizationConfiguration cfg;
				cfg = GlobalizationConfiguration.GetInstance (null);
				if (cfg != null) {
					app_culture = cfg.Culture;
					appui_culture = cfg.UICulture;
				}
#endif
			}
		}
 public HttpModuleCollectionProxy(HttpModuleCollection httpModuleCollection)
 {
     _httpModuleCollection = httpModuleCollection;
 }
		public void FixtureSetUp ()
		{
			coll = new HttpApplication ().Modules;
		}
 internal void DisposeInternal()
 {
     PerfCounters.DecrementCounter(AppPerfCounter.PIPELINES);
     try
     {
         this.Dispose();
     }
     catch (Exception exception)
     {
         this.RecordError(exception);
     }
     if (this._moduleCollection != null)
     {
         int count = this._moduleCollection.Count;
         for (int i = 0; i < count; i++)
         {
             try
             {
                 if (HttpRuntime.UseIntegratedPipeline)
                 {
                     this._currentModuleCollectionKey = this._moduleCollection.GetKey(i);
                 }
                 this._moduleCollection[i].Dispose();
             }
             catch
             {
             }
         }
         this._moduleCollection = null;
     }
 }
 private HttpModuleCollection BuildIntegratedModuleCollection(List<ModuleConfigurationInfo> moduleList)
 {
     HttpModuleCollection modules = new HttpModuleCollection();
     foreach (ModuleConfigurationInfo info in moduleList)
     {
         ModulesEntry entry = new ModulesEntry(info.Name, info.Type, "type", null);
         modules.AddModule(entry.ModuleName, entry.Create());
     }
     return modules;
 }
 private void RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
 {
     RequestNotification notification;
     RequestNotification notification2;
     this.RegisterIntegratedEvent(appContext, "AspNetFilterModule", RequestNotification.LogRequest | RequestNotification.UpdateRequestCache, 0, string.Empty, string.Empty, true);
     this._moduleCollection = this.GetModuleCollection(appContext);
     if (handlers != null)
     {
         this.HookupEventHandlersForApplicationAndModules(handlers);
     }
     HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(context, this);
     this._currentModuleCollectionKey = "global.asax";
     try
     {
         this._hideRequestResponse = true;
         context.HideRequestResponse = true;
         this._context = context;
         this.Init();
     }
     catch (Exception exception)
     {
         this.RecordError(exception);
         Exception error = context.Error;
         if (error != null)
         {
             throw error;
         }
     }
     finally
     {
         this._context = null;
         context.HideRequestResponse = false;
         this._hideRequestResponse = false;
     }
     this.ProcessEventSubscriptions(out notification, out notification2);
     this._appRequestNotifications |= notification;
     this._appPostNotifications |= notification2;
     for (int i = 0; i < this._moduleCollection.Count; i++)
     {
         this._currentModuleCollectionKey = this._moduleCollection.GetKey(i);
         IHttpModule module = this._moduleCollection.Get(i);
         ModuleConfigurationInfo info = _moduleConfigInfo[i];
         module.Init(this);
         this.ProcessEventSubscriptions(out notification, out notification2);
         if ((notification != 0) || (notification2 != 0))
         {
             this.RegisterIntegratedEvent(appContext, info.Name, notification, notification2, info.Type, info.Precondition, false);
         }
     }
     this.RegisterIntegratedEvent(appContext, "ManagedPipelineHandler", RequestNotification.ExecuteRequestHandler | RequestNotification.MapRequestHandler, 0, string.Empty, string.Empty, false);
 }
 private void InitIntegratedModules() {
     Debug.Assert(null != _moduleConfigInfo, "null != _moduleConfigInfo");
     _moduleCollection = BuildIntegratedModuleCollection(_moduleConfigInfo);
     InitModulesCommon();
 }
        private void InitModules() {
            HttpModulesSection pconfig = RuntimeConfig.GetAppConfig().HttpModules;

            // get the static list, then add the dynamic members
            HttpModuleCollection moduleCollection = pconfig.CreateModules();
            HttpModuleCollection dynamicModules = CreateDynamicModules();

            moduleCollection.AppendCollection(dynamicModules);
            _moduleCollection = moduleCollection; // don't assign until all ops have succeeded

            InitModulesCommon();
        }
Exemple #17
0
		public virtual void Dispose ()
		{
			if (modcoll != null) {
				for (int i = modcoll.Count; i >= 0; i--) {
					modcoll.Get (i).Dispose ();
				}
				modcoll = null;
			}

			if (Disposed != null)
				Disposed (this, EventArgs.Empty);
			
			done.Close ();
			done = null;
		}
        private void RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) {
            RequestNotification requestNotifications;
            RequestNotification postRequestNotifications;

            // register an implicit filter module
            RegisterIntegratedEvent(appContext,
                                    IMPLICIT_FILTER_MODULE,
                                    RequestNotification.UpdateRequestCache| RequestNotification.LogRequest  /*requestNotifications*/,
                                    0 /*postRequestNotifications*/,
                                    String.Empty /*type*/,
                                    String.Empty /*precondition*/,
                                    true /*useHighPriority*/);

            // integrated pipeline will always use serverModules instead of <httpModules>
            _moduleCollection = GetModuleCollection(appContext);

            if (handlers != null) {
                HookupEventHandlersForApplicationAndModules(handlers);
            }

            // 1643363: Breaking Change: ASP.Net v2.0: Application_OnStart is called after Module.Init (Integarted mode)
            HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(context, this);

            // Call Init on HttpApplication derived class ("global.asax")
            // and process event subscriptions before processing other modules.
            // Doing this now prevents clearing any events that may
            // have been added to event handlers during instantiation of this instance.
            // NOTE:  If "global.asax" has a constructor which hooks up event handlers,
            // then they were added to the event handler lists but have not been registered with IIS yet,
            // so we MUST call ProcessEventSubscriptions on it first, before the other modules.
            _currentModuleCollectionKey = HttpApplicationFactory.applicationFileName;

            try {
                _hideRequestResponse = true;
                context.HideRequestResponse = true;
                _context = context;
                Init();
            }
            catch (Exception e) {
                RecordError(e);
                Exception error = context.Error;
                if (error != null) {
                    throw error;
                }
            }
            finally {
                _context = null;
                context.HideRequestResponse = false;
                _hideRequestResponse = false;
            }

            ProcessEventSubscriptions(out requestNotifications, out postRequestNotifications);

            // Save the notification subscriptions so we can register them with IIS later, after
            // we call HookupEventHandlersForApplicationAndModules and process global.asax event handlers.
            _appRequestNotifications |= requestNotifications;
            _appPostNotifications    |= postRequestNotifications;

            for (int i = 0; i < _moduleCollection.Count; i++) {
                _currentModuleCollectionKey = _moduleCollection.GetKey(i);
                IHttpModule httpModule = _moduleCollection.Get(i);
                ModuleConfigurationInfo moduleInfo = _moduleConfigInfo[i];

#if DBG
                Debug.Trace("PipelineRuntime", "RegisterEventSubscriptionsWithIIS: name=" + CurrentModuleCollectionKey
                            + ", type=" + httpModule.GetType().FullName + "\n");

                // make sure collections are in [....]
                Debug.Assert(moduleInfo.Name == _currentModuleCollectionKey, "moduleInfo.Name == _currentModuleCollectionKey");
#endif

                httpModule.Init(this);

                ProcessEventSubscriptions(out requestNotifications, out postRequestNotifications);

                // are any events wired up?
                if (requestNotifications != 0 || postRequestNotifications != 0) {

                    RegisterIntegratedEvent(appContext,
                                            moduleInfo.Name,
                                            requestNotifications,
                                            postRequestNotifications,
                                            moduleInfo.Type,
                                            moduleInfo.Precondition,
                                            false /*useHighPriority*/);
                }
            }

            // WOS 1728067: RewritePath does not remap the handler when rewriting from a non-ASP.NET request
            // register a default implicit handler
            RegisterIntegratedEvent(appContext,
                                    IMPLICIT_HANDLER,
                                    RequestNotification.ExecuteRequestHandler | RequestNotification.MapRequestHandler /*requestNotifications*/,
                                    RequestNotification.EndRequest /*postRequestNotifications*/,
                                    String.Empty /*type*/,
                                    String.Empty /*precondition*/,
                                    false /*useHighPriority*/);
        }
 public static IHttpModuleCollection Cast(HttpModuleCollection modules)
 {
     return new HttpModuleCollectionProxy(modules);
 }
 internal void AppendCollection(HttpModuleCollection other) {
     // appends another collection to this instance (mutates this instance)
     for (int i = 0; i < other.Count; i++) {
         AddModule(other.BaseGetKey(i), other.Get(i));
     }
 }
 private void InitIntegratedModules()
 {
     this._moduleCollection = this.BuildIntegratedModuleCollection(_moduleConfigInfo);
     this.InitModulesCommon();
 }