예제 #1
0
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                //try
                //{
                DbContextSeedData.Seed(services);
                //}
                //catch (Exception ex)
                //{
                //    var logger = services.GetRequiredService<ILogger<Program>>();
                //    logger.LogError(ex, "An error occurred seeding the DB.");
                //}
            }
            host.Run();
        }
예제 #2
0
파일: Startup.cs 프로젝트: jphacks/TH_1602
        // 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, DbContextSeedData seeder)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseApplicationInsightsRequestTelemetry();

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

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            app.UseIdentity();

            app.UseCors("AllowAll");

            seeder.SeedAdminUserAsync("p@ssw0rd").Wait();

            seeder.SeedUserAsync().Wait();

            seeder.SeedCategory().Wait();

            seeder.SeedObjectTag().Wait();

            app.UseTwitterAuthentication(new TwitterOptions()
            {
                ConsumerKey    = Configuration.GetValue <string>("AppTokens:TwitterConsumerKey"),
                ConsumerSecret = Configuration.GetValue <string>("AppTokens:TwitterConsumerSecret")
            });

            app.UseMiddleware <AccessTokenMiddleware>();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }