Ejemplo n.º 1
0
        /// <summary>
        /// Create a handler instance for the given URL.
        /// </summary>
        /// <param name="appContext">the application context corresponding to the current request</param>
        /// <param name="context">The <see cref="HttpContext"/> instance for this request.</param>
        /// <param name="requestType">The HTTP data transfer method (GET, POST, ...)</param>
        /// <param name="rawUrl">The requested <see cref="HttpRequest.RawUrl"/>.</param>
        /// <param name="physicalPath">The physical path of the requested resource.</param>
        /// <returns>A handler instance for the current request.</returns>
        protected override IHttpHandler CreateHandlerInstance(IConfigurableApplicationContext appContext, HttpContext context, string requestType, string rawUrl, string physicalPath)
        {
            IHttpHandler handler;

            string appRelativeVirtualPath             = WebUtils.GetAppRelativePath(rawUrl);
            NamedObjectDefinition namedPageDefinition = FindWebObjectDefinition(appRelativeVirtualPath, appContext.ObjectFactory);

            if (namedPageDefinition != null)
            {
                // is this a nested call (HttpServerUtility.Transfer() or HttpServerUtility.Execute())?
                if (context.Handler != null)
                {
                    // all deps can/must be resolved now
                    handler = (IHttpHandler)appContext.GetObject(namedPageDefinition.Name, typeof(IHttpHandler), null);
                }
                else
                {
                    // execution pipeline "entry-point" - create page instance only
                    // and defer configuration to PreRequestHandlerExecute step
                    handler = (IHttpHandler)appContext.CreateObject(namedPageDefinition.Name, typeof(IHttpHandler), null);
                    WebSupportModule.ConfigureHandler(context, handler, appContext, namedPageDefinition.Name, true);
                }
            }
            else
            {
                handler = WebObjectUtils.CreateHandler(rawUrl);
                // let WebSupportModule handle configuration
                handler = WebSupportModule.ConfigureHandler(context, handler, appContext, rawUrl, false);
            }

            return(handler);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a handler instance for the given URL.
        /// </summary>
        /// <param name="appContext">the application context corresponding to the current request</param>
        /// <param name="context">The <see cref="HttpContext"/> instance for this request.</param>
        /// <param name="requestType">The HTTP data transfer method (GET, POST, ...)</param>
        /// <param name="rawUrl">The requested <see cref="HttpRequest.RawUrl"/>.</param>
        /// <param name="physicalPath">The physical path of the requested resource.</param>
        /// <returns>A handler instance for processing the current request.</returns>
        protected override IHttpHandler CreateHandlerInstance(IConfigurableApplicationContext appContext, HttpContext context, string requestType, string rawUrl, string physicalPath)
        {
            IHttpHandler handler = _innerFactory.GetHandler(context, requestType, rawUrl, physicalPath);

            // find a matching object definition
            string appRelativeVirtualPath = WebUtils.GetAppRelativePath(rawUrl);
            NamedObjectDefinition nod     = FindWebObjectDefinition(appRelativeVirtualPath, appContext.ObjectFactory);
            string objectDefinitionName   = (nod != null) ? nod.Name : rawUrl;

            handler = WebSupportModule.ConfigureHandler(context, handler, appContext, objectDefinitionName, (nod != null));
            return(handler);
        }