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, IHostingEnvironment env, ISeedDatabase seedDatabase)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            // Enables autentication capabilities
            app.UseAuthentication();

            // initalize databse with default data
            seedDatabase.Initalize();

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Esempio n. 2
0
        protected virtual void Seed(T context)
        {
            ISeedDatabase seeder = context as ISeedDatabase;

            if (seeder != null)
            {
                seeder.Seed();
            }
        }
        private static void SeedDatabase(MileageStatsDbContext context)
        {
            ISeedDatabase seeder = context as ISeedDatabase;

            if (seeder != null)
            {
                seeder.Seed();
            }
        }
Esempio n. 4
0
        protected override void Seed(VnrHrmDataContext context)
        {
            ISeedDatabase seeder = context as ISeedDatabase;

            if (seeder != null)
            {
                seeder.Seed();
            }
        }
Esempio n. 5
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISeedDatabase seedDatabase)
        {
            /*  NOTE:
             *  For Visual Studio, the URL's used during development are in
             *      (WebApp) Project -> Properties -> Debug. Currently:
             *      "App URL" = "http:/localhost:36029"
             *      "Enable SSL" is checked. "https:/localhost:44333/"
             *  For "dotnet run", the dev URL's are in WebApp\Properties\launchSettings.json,
             *    Currently for IISExpress:
             *      "applicationUrl": "http://localhost:36029",
             *      "sslPort": 44333
             *  For VsCode, the dev URL's are in clientapp/.vscode/launch.json. Currently:
             *      "url": "http:/localhost:4200"
             */

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

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            if (!env.IsDevelopment())
            {
                app.UseSpaStaticFiles();
            }

            app.UseRouting();

            // START OF ENDPOINT ZONE

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

            DebugCurrentEndpoint(app);

            // END OF ENDPOINT ZONE

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
                //endpoints.MapHealthChecks("/health").RequireAuthorization();
            });

            app.UseOpenApi();
            app.UseSwaggerUi3();

            app.UseSpa(spa =>
            {
                // To learn more about options for serving an Angular SPA from ASP.NET Core,
                // see https://go.microsoft.com/fwlink/?linkid=864501

                spa.Options.SourcePath = "clientapp";

                if (env.IsDevelopment())
                {
                    // spa.UseAngularCliServer(npmScript: "start");
                    spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
                }
            });

            //seedDatabase.Seed();
        }