예제 #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, RoleManager <IdentityRole> roleManager,
                              UserManager <IdentityUser> userManager)
        {
            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?}");
            });

            SetupSecurity.SeedRoles(roleManager);
            SetupSecurity.SeedUsers(userManager);
        }
예제 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDbContext <BlindDatingContext>(options =>
                                                       options.UseSqlServer(Configuration.GetConnectionString("Dating")));
            services.AddDbContext <SecurityContext>(options =>
                                                    options.UseSqlServer(Configuration.GetConnectionString("Dating")));

            services.AddIdentity <IdentityUser, IdentityRole>()
            .AddEntityFrameworkStores <SecurityContext>()
            // .AddDefaultUI()
            // .AddDefaultTokenProviders();
            ;
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            SetupSecurity.SeedRoles(roleManager);
            SetupSecurity.SeedUsers(userManager);
        }