示例#1
0
        /// <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);
        }
示例#2
0
        public void SetApplicationUrlViaProvider()
        {
            // no applicable settings, but a provider

            var settings = Mock.Of <IUmbracoSettingsSection>(section =>
                                                             section.DistributedCall == Mock.Of <IDistributedCallSection>(callSection => callSection.Servers == Enumerable.Empty <IServer>()) &&
                                                             section.WebRouting == Mock.Of <IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == (string)null) &&
                                                             section.ScheduledTasks == Mock.Of <IScheduledTasksSection>());

            ApplicationUrlHelper.ApplicationUrlProvider = request => "http://server1.com/umbraco";

            Initialize(settings);

            var appCtx = new ApplicationContext(CacheHelper.CreateDisabledCacheHelper(),
                                                new ProfilingLogger(Mock.Of <ILogger>(), Mock.Of <IProfiler>()));

            ConfigurationManager.AppSettings.Set("umbracoUseSSL", "true"); // does not make a diff here

            ApplicationUrlHelper.EnsureApplicationUrl(appCtx, settings: settings);

            Assert.AreEqual("http://server1.com/umbraco", appCtx._umbracoApplicationUrl);
        }