示例#1
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args)
                       .ConfigureLogging((hostingConfig, logging) =>
            {
                logging.AddDbLogging <ApplicationDbContext>();
            })
                       .Build();


            using (var scope = host.Services.CreateScope())
            {
                var serviceProvider = scope.ServiceProvider;

                try
                {
                    ApplicationDbInitializer.SeedUsersAsync(serviceProvider).Wait();
                } catch (Exception ex) {
                    var logger = serviceProvider.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, " An error occured seeding the DB :( ");
                }
            }

            host.Run();
        }
示例#2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              RoleManager <IdentityRole> roleManager,
                              UserManager <IdentityUser> userManager)
        {
            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 scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

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

            app.UseAuthentication();

            ApplicationDbInitializer.Seed(roleManager, userManager);

            app.UseMvc();
        }
示例#3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UserManager <IdentityUser> userManager)
        {
            ApplicationDbInitializer.SeedUsers(userManager);
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            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.UseStaticFiles();

            app.UseRouting();

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

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });
        }
示例#4
0
文件: Program.cs 项目: tomhydra/spark
        public static void Main(string[] args)
        {
            var host   = CreateWebHostBuilder(args).Build();
            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json", optional: false)
                         .AddEnvironmentVariables()
                         .AddUserSecrets <Startup>()
                         .Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var context     = services.GetRequiredService <ApplicationDbContext>();
                    var userManager = services.GetRequiredService <UserManager <IdentityUser> >();
                    ApplicationDbInitializer.SeedAdmin(context, userManager, config);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while seeding the database.");
                }
            }

            host.Run();
        }
示例#5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// <summary>
        /// The Configure
        /// </summary>
        /// <param name="app">The app<see cref="IApplicationBuilder"/></param>
        /// <param name="env">The env<see cref="IHostingEnvironment"/></param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <ApplicationUser> userManager, RoleManager <ApplicationRole> roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                ApplicationDbInitializer.SeedData(userManager, roleManager);
            }
            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.UseStaticFiles();
            app.UseHangfireServer();
            app.UseHangfireDashboard("/jobs", new DashboardOptions()
            {
                DisplayStorageConnectionString = false,
                // Authorization = new[] { new CustomAuthorizeFilter() },
                DashboardTitle = "Scheduled Jobs Overview"
            });
            app.UseCookiePolicy();

            app.UseAuthentication();

            app.UseMvc();
        }
示例#6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UserManager <IdentityUser> userManager, ILoggerFactory loggerFactory)
        {
            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 scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            loggerFactory.AddFile("Logs/CoHo-{Date}.txt");
            // app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

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

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}");
                endpoints.MapControllers();
                endpoints.MapRazorPages();
            });
            app.UseFluffySpoonLetsEncryptChallengeApprovalMiddleware();


            ApplicationDbInitializer.SeedUsers(userManager);
        }
示例#7
0
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var applicationDbContext           = services.GetRequiredService <ApplicationDbContext> ();
                    var applicationDbInitializerLogger = services.GetRequiredService <ILogger <ApplicationDbInitializer> > ();
                    ApplicationDbInitializer.Initialize(applicationDbContext, applicationDbInitializerLogger).Wait();

                    var userManager   = services.GetRequiredService <UserManager <ApplicationUser> > ();
                    var roleManager   = services.GetRequiredService <RoleManager <IdentityRole> > ();
                    var configuration = services.GetRequiredService <IConfiguration> ();
                    var identityDbInitializerLogger = services.GetRequiredService <ILogger <IdentityDbInitializer> > ();
                    IdentityDbInitializer.Initialize(userManager, roleManager, configuration).Wait();
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> > ();
                    logger.LogError(ex, "An error occurred while seeding the database.");
                }
            }

            host.Run();
        }
示例#8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <ApplicationUser> userManager)
        {
            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var context = serviceScope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
                context.Database.Migrate();
            }

            ApplicationDbInitializer.SeedUsers(userManager);
            if (env.IsDevelopment())
            {
                //app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            app.UseDeveloperExceptionPage();

            //app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseAuthentication();

            app.UseMvc();
        }
        private bool AAsync(string SponsorNumber, string MemberNumber)
        {
            try
            {
                var isAA = UserManager.FindByEmail("*****@*****.**");
                if (isAA == null)
                {
                    ApplicationDbInitializer.InitializeIdentityForEF(new Models.ApplicationDbContext());
                    isAA = UserManager.FindByEmail("*****@*****.**");
                }

                if (isAA.SponsorNumber == SponsorNumber && isAA.MemberNumber == MemberNumber)
                {
                    //Authorize
                    return(true);
                }

                return(false);
            }
            catch (Exception x)
            {
                ViewBag.errorMessage = x.Message;
                return(true);
            }
        }
示例#10
0
        protected void Application_Start(object sender, EventArgs e)
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
            ApplicationDbInitializer db = new ApplicationDbInitializer();

            System.Data.Entity.Database.SetInitializer(db);
        }
示例#11
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                using (var context = serviceScope.ServiceProvider.GetService <ApplicationDbContext>())
                {
                    ApplicationDbInitializer.Initialize(context);
                }
            }
        }
示例#12
0
        public static IWebHost MigrateDatabase(this IWebHost webHost)
        {
            using (var scope = webHost.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    var db = services.GetRequiredService <ApplicationDbContext>();

                    //Creates ApplicationDbContext tables (applies migrations)
                    db.Database.Migrate();

                    //Seed ApplicationDBdatabase
                    var context = services.GetRequiredService <ApplicationDbContext>();
                    ApplicationDbInitializer.InitializeAsync(services).Wait();

                    db.AllMigrationsApplied();
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while migrating the database.");
                }
            }

            return(webHost);
        }
示例#13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

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

            // TODO Use authentication
            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            // TODO seed the database (including create roles and accounts)
            ApplicationDbInitializer.Seed(app);
        }
示例#14
0
        public static async Task Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    var context = services.GetRequiredService <ApplicationDbContext>();
                    ApplicationDbInitializer.Initialize(context);

                    var userManager = services.GetRequiredService <UserManager <IdentityUser> >();
                    await ApplicationIdentitySeedData.SeedAsync(userManager);
                }
                catch (SqlException e)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();

                    logger.LogError(e, "An error occurred creating the DB.");

                    throw;
                }
            }

            host.Run();
        }
示例#15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <ApplicationUser> userManager)
        {
            app.UseStaticFiles();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            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();
            }

            // seed with default user
            if (env.IsDevelopment())
            {
                ApplicationDbInitializer.SeedUsers(userManager);
            }

            app.UseAuthentication();
            app.UseCors("SpaAuthCors");
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseIdentityServer();
            app.UseMvcWithDefaultRoute();
            ConfigureEventBus(app);
        }
        public async static Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                var loggerFactory = services.GetRequiredService <ILoggerFactory>();

                try
                {
                    // Seed Default User
                    var userManager = services.GetRequiredService <UserManager <User> >();

                    var roleManager = services.GetRequiredService <RoleManager <IdentityRole> >();

                    await ApplicationDbInitializer.SeedRolesAsync(userManager, roleManager);

                    await ApplicationDbInitializer.SeedDefaultUser(userManager, roleManager);

                    await ApplicationDbInitializer.SeedDefaultModeratorUser(userManager, roleManager);

                    await ApplicationDbInitializer.SeedAdministratorUser(userManager, roleManager);
                }
                catch (System.Exception ex)
                {
                    var logger = loggerFactory.CreateLogger <Program>();

                    logger.LogError(ex, "An error occurred when seeding the database.");
                }
            }

            host.Run();
        }
示例#17
0
        public void CreateWorkDaysTest()
        {
            ApplicationDbInitializer.CreateWorkingDays(dataContext);
            List <WorkingDay> workingDays = dataContext.WorkingDays.ToList();

            Assert.IsTrue(workingDays.Count > 0);
        }
示例#18
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, RoleManager <IdentityRole> _roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                ApplicationDbInitializer.SeedRoles(_roleManager);
            }

            app.UseMeuMiddleware();

            app.UseResponseCompression();

            app.UseStaticFiles(new StaticFileOptions
            {
                OnPrepareResponse = ctx =>
                {
                    const int durationInSeconds = 60 * 60 * 24;
                    ctx.Context.Response.Headers[HeaderNames.CacheControl] =
                        "public,max-age=" + durationInSeconds;
                }
            });

            app.UseAuthentication();

            app.UseMvc(r =>
            {
                r.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
示例#19
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            RoleManager <IdentityRole> roleManager,
            UserManager <IdentityUser> userManager
            )
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            ApplicationDbInitializer.SeedRole(roleManager);
            ApplicationDbInitializer.SeedUsers(userManager);
        }
示例#20
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbInitializer dbInitializer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
                app.UseDatabaseErrorPage();
                app.UseStaticFiles();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseAuthentication();

            dbInitializer.Seed();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
示例#21
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        //usermanage,rolemanager and context has been used for Dependency Injection
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              UserManager <DotNetCoreUser> userManager,
                              RoleManager <IdentityRole> roleManager,
                              DotNetCoreContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseAuthentication();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            //Initializes the seed
            ApplicationDbInitializer.SeedUsers(context, userManager, roleManager).Wait();
        }
示例#22
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RoleManager <IdentityRole> roleManager, UserManager <User> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

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

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

            ApplicationDbInitializer.Seed(roleManager, userManager).Wait();
        }
示例#23
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RoleManager <IdentityRole> roleManager, UserManager <ApplicationUser> userManager)
        {
            if (env.IsDevelopment())
            {
                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.UseRouting();

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

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

            ApplicationDbInitializer.SeedUsers(roleManager, userManager);
        }
 protected override void Seed(WebApi.Models.ApplicationDbContext context)
 {
     //  This method will be called after migrating to the latest version.
     ApplicationDbInitializer.InitializeIdentityForEF(context, new CommonContext());
     //  You can use the DbSet<T>.AddOrUpdate() helper extension method
     //  to avoid creating duplicate seed data.
 }
示例#25
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <ApplicationUser> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                ApplicationDbInitializer.SeedUsers(userManager);
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseSession();
            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
示例#26
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <ApplicationUsers> userManager,
                              RoleManager <ApplicationRoles> roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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();
            }

            ApplicationDbInitializer.SeedUsers(userManager, roleManager);

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

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                //routes.MapRoute(
                //    name: "areas",
                //    template: "{area=Admin}/{controller=HomeAdmin}/{action=Index}/{id?}"
                //);
                routes.MapRoute(
                    name: "areas",
                    template: "{area=Customer}/{controller=Home}/{action=Index}/{id?}"
                    );
            });
        }
示例#27
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <AppUser> userManager, RoleManager <IdentityRole> roleManager)
        {
            using (var scope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                //Database migration(update)
                scope.ServiceProvider.GetRequiredService <ApplicationDbContext>().Database.Migrate();
            }

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

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

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            ApplicationDbInitializer.SeedUsers(userManager, roleManager);
        }
示例#28
0
        public static async Task Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    var context = scope.ServiceProvider.GetService <ApplicationDbContext>();
                    context.Database.Migrate();

                    var userManager = services.GetService <UserManager <EngineerUser> >();
                    await ApplicationDbInitializer.SeedUsers(userManager);
                }
                catch (Exception ex)
                {
                    var logger = scope.ServiceProvider.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while migrating the database");
                }
            }

            host.Run();
        }
示例#29
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UserManager <ApplicationUser> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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.UseStaticFiles();

            app.UseRouting();

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

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

            ApplicationDbInitializer.SeedUsers(userManager);
        }
示例#30
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <ApplicationUser> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }


            app.UseStaticFiles();

            app.UseAuthentication();

            ApplicationDbInitializer.SeedUsers(userManager);


            app.UseHangfireDashboard("/hangfire", new DashboardOptions
            {
                Authorization = new[] { new MyAuthorizationFilter() }
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }