コード例 #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
                              , UserManager <ApplicationUser> userManager
                              , RoleManager <IdentityRole> roleManager
                              , ApplicationDbContext dbContext
                              )
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseAuthentication();
            app.UseSession();

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



            dbContext.Database.EnsureCreated();
            IdentityInitializer.SeedRoles(roleManager);
            IdentityInitializer.SeedUsers(userManager);
        }
コード例 #2
0
 public IActionResult Users()
 {
     IdentityInitializer.SeedUsers(_userManager, _applicationDbContext);
     return(Ok("Seed Users completed successfully"));
 }