Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              ILoggerFactory loggerFactory,
                              ISiteInstallationService siteInstallationService,
                              IAppInstallationService appInstallationService,
                              IMembershipInstallationService membershipInstallationService,
                              ISiteRepository siteRepository,
                              ILanguageFacade languageFacade,
                              IPageFacade pageFacade)
        {
            appInstallationService.VerifyAppInstallation();
            siteInstallationService.VerifySiteInstallation();
            membershipInstallationService.VerifyUserCreation();

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseApplicationInsightsRequestTelemetry();

            app.UseStatusCodePagesWithRedirects("~/error/{0}");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/error/500");
            }

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            app.UseIdentity();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715

            var site            = siteRepository.GetByName("Default");
            var activeLanguages = languageFacade.GetAllActive(site.Id);
            var pages           = pageFacade.GetAllForAdminAsync(site.Id).Result;

            app.AddRoutes(site, activeLanguages, pages);
            app.AddLocalisation(activeLanguages);
        }
Ejemplo n.º 2
0
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment hostingEnvironment,
                              ILoggerFactory loggerFactory,
                              ISiteInstallationService siteInstallationService,
                              IAppInstallationService appInstallationService,
                              IMembershipInstallationService membershipInstallationService,
                              ISiteRepository siteRepository,
                              ILanguageFacade languageFacade,
                              IPageFacade pageFacade)
        {
            membershipInstallationService.VerifyUserCreation();
            appInstallationService.VerifyAppInstallation();
            siteInstallationService.VerifySiteInstallation();

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseApplicationInsightsRequestTelemetry();

            app.UseStatusCodePagesWithRedirects("~/error/{0}");

            if (hostingEnvironment.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/error/500");
            }

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            foreach (var appDescriptor in AppLoader.Instance(hostingEnvironment).AppDescriptors)
            {
                var contentPath = Path.Combine(hostingEnvironment.ContentRootPath, "Apps", appDescriptor.Folder, "wwwroot");
                if (Directory.Exists(contentPath))
                {
                    app.UseStaticFiles(new StaticFileOptions
                    {
                        RequestPath  = "/" + appDescriptor.Folder,
                        FileProvider = new PhysicalFileProvider(contentPath)
                    });
                }
            }

            foreach (var startup in AppLoader.Instance(hostingEnvironment).AppAssemblies.GetTypes <Mvc.Apps.IStartup>())
            {
                startup.Configure(app);
            }

            var applicationPartManager = app.ApplicationServices.GetRequiredService <ApplicationPartManager>();

            Parallel.ForEach(AppLoader.Instance(hostingEnvironment).AppAssemblies, assembly =>
            {
                applicationPartManager.ApplicationParts.Add(new AssemblyPart(assembly));
            });

            app.UseIdentity();

            var site            = siteRepository.GetByName("Default");
            var activeLanguages = languageFacade.GetAllActiveAsync(site.Id).Result;

            app.AddRoutes();
            app.AddLocalisation(activeLanguages);
        }