示例#1
0
        public static void Main(string[] args)
        {
            //CreateWebHostBuilder(args).Build().Run();
            var webHost = BuildWebHost(args);

            using (var scope = webHost.Services.CreateScope())
            {
                DBFirstDbInitializer initializer = scope.ServiceProvider
                                                        .GetService<DBFirstDbInitializer>();

                int rowAffected = initializer.PlantSeedData();
            }

            webHost.Run();
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, /*IHostingEnvironment*/ IWebHostEnvironment env, DBFirstDbInitializer seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseCookiePolicy();

            // Version 3.1에서 라우팅 지정 분리됨
            app.UseRouting();

            // 신원보증
            app.UseAuthentication();

            // 권한승인(Version 3.1)
            app.UseAuthorization();

            //app.UseMvc() 위에 있어야함
            app.UseSession();

            // Version 2.1
            // MVC 라우팅 및 종착지 지정
            //app.UseMvc(routes =>
            //{
            //    routes.MapRoute(
            //        name: "default",
            //        template: "{controller=Home}/{action=Index}/{id?}");
            //});

            // Version 3.1
            // 종착지 지정
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });

            seeder.PlantSeedData();
        }