Esempio n. 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              AtlasDbContext atlasDbContext,
                              ApplicationDbContext applicationDbContext,
                              IInstallationService installationService,
                              IDocumentationService documentationService)
        {
            if (env.IsDevelopment())
            {
                app.UseExceptionHandler("/Error");

                //app.UseDeveloperExceptionPage();
                //app.UseDatabaseErrorPage();
                app.UseWebAssemblyDebugging();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseBlazorFrameworkFiles();
            app.UseStaticFiles();
            //app.UseStaticFiles(new StaticFileOptions
            //{
            //    FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"Uploads")),
            //    RequestPath = new PathString("/Uploads")
            //});

            app.UseRouting();

            app.UseIdentityServer();
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapControllers();
                endpoints.MapFallbackToFile("index.html");
            });

            if (Configuration["MigrateDatabases"] == "true")
            {
                atlasDbContext.Database.Migrate();
                applicationDbContext.Database.Migrate();
            }

            if (Configuration["EnsureDefaultSiteInitialized"] == "true")
            {
                installationService.EnsureDefaultSiteInitializedAsync().Wait();
            }

            if (Configuration["GenerateDocumentationOnStartup"] == "true")
            {
                documentationService.Generate(typeof(Site).Assembly);
            }
        }