/// <summary> /// Begins to process a request. /// </summary> /// <param name="httpContext"></param> private void BeginRequest(HttpContextBase httpContext) { // ensure application url is initialized ((RuntimeState)Current.RuntimeState).EnsureApplicationUrl(httpContext.Request); // 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 UmbracoContext singleton, one per request, and assign // replace existing if any (eg during app startup, a temp one is created) UmbracoContext.EnsureContext( _umbracoContextAccessor, httpContext, _publishedSnapshotService, new WebSecurity(httpContext, _userService, _globalSettings), Current.Configs.Settings(), _urlProviders, _globalSettings, _variationContextAccessor, true); }
/// <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); }
/// <summary> /// Begins to process a request. /// </summary> /// <param name="httpContext"></param> static void BeginRequest(HttpContextBase httpContext) { // ensure application url is initialized ApplicationUrlHelper.EnsureApplicationUrl(ApplicationContext.Current, httpContext.Request); // 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, new WebSecurity(httpContext, ApplicationContext.Current), true); }
/// <summary> /// Override this method in order to ensure that the UmbracoContext is also created, this can only be /// created after resolution is frozen! /// </summary> protected override void FreezeResolution() { base.FreezeResolution(); //before we do anything, we'll ensure the umbraco context //see: http://issues.umbraco.org/issue/U4-1717 UmbracoContext.EnsureContext(new HttpContextWrapper(UmbracoApplication.Context), ApplicationContext); }
/// <summary> /// Override this method in order to ensure that the UmbracoContext is also created, this can only be /// created after resolution is frozen! /// </summary> protected override void FreezeResolution() { base.FreezeResolution(); //before we do anything, we'll ensure the umbraco context //see: http://issues.umbraco.org/issue/U4-1717 var httpContext = new HttpContextWrapper(UmbracoApplication.Context); UmbracoContext.EnsureContext( httpContext, ApplicationContext, new WebSecurity(httpContext, ApplicationContext), UmbracoConfig.For.UmbracoSettings(), UrlProviderResolver.Current.Providers, false); }