private void AddSendResponseEventHookup(object key, Delegate handler) {
            ThrowIfEventBindingDisallowed();

            // add the event to the delegate invocation list
            // this keeps non-pipeline ASP.NET hosts working
            Events.AddHandler(key, handler);

            // For integrated pipeline mode, add events to the IExecutionStep containers only if
            // InitSpecial has completed and InitInternal has not completed.
            if (IsContainerInitalizationAllowed) {
                // lookup the module index and add this notification
                PipelineModuleStepContainer container = GetModuleContainer(CurrentModuleCollectionKey);
                //WOS 1985878: HttpModule unsubscribing an event handler causes AV in Integrated Mode
                if (container != null) {
#if DBG
                    container.DebugModuleName = CurrentModuleCollectionKey;
#endif
                    bool isHeaders = (key == EventPreSendRequestHeaders);
                    SendResponseExecutionStep step = new SendResponseExecutionStep(this, (EventHandler)handler, isHeaders);
                    container.AddEvent(RequestNotification.SendResponse, false /*isPostNotification*/, step);
                }
            }
        }
 private void AddSendResponseEventHookup(object key, Delegate handler)
 {
     this.ThrowIfEventBindingDisallowed();
     this.Events.AddHandler(key, handler);
     if (this.IsContainerInitalizationAllowed)
     {
         PipelineModuleStepContainer moduleContainer = this.GetModuleContainer(this.CurrentModuleCollectionKey);
         if (moduleContainer != null)
         {
             bool isHeaders = key == EventPreSendRequestHeaders;
             SendResponseExecutionStep step = new SendResponseExecutionStep(this, (EventHandler) handler, isHeaders);
             moduleContainer.AddEvent(RequestNotification.SendResponse, false, step);
         }
     }
 }