예제 #1
0
        /// <summary>
        /// Initializes a module and prepares it to handle requests.
        /// </summary>
        /// <param name="context">
        /// An <see cref="T:System.Web.HttpApplication"/> that provides
        /// access to the methods, properties, and events common to all
        /// application objects within an ASP.NET application
        /// </param>
        public void Init(HttpApplication context)
        {
            if (!this.hasModuleInitialized)
            {
                Interlocked.CompareExchange(ref initCheck, 1, 0);
                DiskCache.CreateDirectories();
            }

#if NET45
            EventHandlerTaskAsyncHelper wrapper = new EventHandlerTaskAsyncHelper(this.PostAuthorizeRequest);
            context.AddOnPostAuthorizeRequestAsync(wrapper.BeginEventHandler, wrapper.EndEventHandler);
#else
            context.PostAuthorizeRequest += this.PostAuthorizeRequest;
#endif

            context.PreSendRequestHeaders += this.ContextPreSendRequestHeaders;
        }