/// <summary> /// Begins to process a request. /// </summary> /// <param name="httpContext"></param> void BeginRequest(HttpContextBase httpContext) { // do not process if client-side request if (IsClientSideRequest(httpContext.Request.Url)) return; // ok, process // create the LegacyRequestInitializer // and initialize legacy stuff var legacyRequestInitializer = new LegacyRequestInitializer(httpContext.Request.Url, httpContext); legacyRequestInitializer.InitializeRequest(); // create the UmbracoContext singleton, one per request, and assign var umbracoContext = new UmbracoContext( httpContext, ApplicationContext.Current, RoutesCacheResolver.Current.RoutesCache); UmbracoContext.Current = umbracoContext; // create the nice urls provider var niceUrls = new NiceUrlProvider(PublishedContentStoreResolver.Current.PublishedContentStore, umbracoContext); // create the RoutingContext, and assign var routingContext = new RoutingContext( umbracoContext, DocumentLookupsResolver.Current.DocumentLookups, LastChanceLookupResolver.Current.LastChanceLookup, PublishedContentStoreResolver.Current.PublishedContentStore, niceUrls); umbracoContext.RoutingContext = routingContext; }
/// <summary> /// Begins to process a request. /// </summary> /// <param name="httpContext"></param> static void BeginRequest(HttpContextBase httpContext) { //we need to set the initial url in our ApplicationContext, this is so our keep alive service works and this must //exist on a global context because the keep alive service doesn't run in a web context. //we are NOT going to put a lock on this because locking will slow down the application and we don't really care //if two threads write to this at the exact same time during first page hit. //see: http://issues.umbraco.org/issue/U4-2059 if (ApplicationContext.Current.OriginalRequestUrl.IsNullOrWhiteSpace()) { ApplicationContext.Current.OriginalRequestUrl = string.Format("{0}:{1}{2}", httpContext.Request.ServerVariables["SERVER_NAME"], httpContext.Request.ServerVariables["SERVER_PORT"], IOHelper.ResolveUrl(SystemDirectories.Umbraco)); } // do not process if client-side request if (httpContext.Request.Url.IsClientSideRequest()) return; //write the trace output for diagnostics at the end of the request httpContext.Trace.Write("UmbracoModule", "Umbraco request begins"); // ok, process // create the LegacyRequestInitializer // and initialize legacy stuff var legacyRequestInitializer = new LegacyRequestInitializer(httpContext.Request.Url, httpContext); legacyRequestInitializer.InitializeRequest(); // create the UmbracoContext singleton, one per request, and assign // NOTE: we assign 'true' to ensure the context is replaced if it is already set (i.e. during app startup) UmbracoContext.EnsureContext(httpContext, ApplicationContext.Current, true); }