// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <IdentityUser> userManager, RoleManager <IdentityRole> rolesManager)
        {
            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.UseCookiePolicy();

            app.UseAuthentication();

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

            ApplicationDbInitializer.SeedRoles(rolesManager);
            ApplicationDbInitializer.SeedUsers(userManager);
        }
Example #2
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?}");
            });
        }
Example #3
0
        public void Configure(
            IRoleService rolesService,
            IMapper mapper,
            IApplicationBuilder app,
            IWebHostEnvironment env,
            IUserService userService,
            CrmContext dataContext,
            IServiceProvider serviceProvider,
            IConfiguration configuration)
        {
            dataContext.Database.Migrate();
            ApplicationDbInitializer.SeedRoles(rolesService);
            ApplicationDbInitializer.SeedUsers(userService);
            MailCredentialsHelper.CheckIfCredentialsExist(
                new MailCredentials(
                    new MailAddress(
                        Configuration["MailAddress"] ?? "*****@*****.**",
                        Configuration["MailDisplayName"] ?? "CRMS-Team"),
                    new System.Net.NetworkCredential(Configuration["MailUserName"] ?? "*****@*****.**",
                                                     Configuration["MailPassword"] ?? "password"),
                    int.Parse(Configuration["MailPort"] ?? "587"),
                    Configuration["MailHost"] ?? "smtp.a.com"));
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseOpenApi();
            app.UseSwaggerUi3();

            app.UseHttpsRedirection();

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

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapHealthChecks("/health");
            });

            app.UseStaticFiles();
            if (!env.IsDevelopment())
            {
                app.UseSpaStaticFiles();
            }
            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "wwwroot";
            });
            new UserCheckThread(serviceProvider.CreateScope().ServiceProvider.GetService <IUserCheckDateService>(), serviceProvider.CreateScope().ServiceProvider.GetService <IContactCheckDateService>(), configuration).runScheduledService().Wait();
        }
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext applicationDbContext, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager)
        {
            app.UseAuthentication();

            //app.UseHsts();
            //app.UseHttpsRedirection();

            app.UseCors("CorsPolicy");

            app.UseMvc();

            //applicationDbContext.Database.EnsureDeleted();

            applicationDbContext.Database.EnsureCreated();

            ApplicationDbInitializer.SeedRoles(roleManager);
            ApplicationDbInitializer.SeedUsers(userManager);
        }
Example #5
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, RoleManager <IdentityRole <Guid> > roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
                {
                    using (var context = serviceScope.ServiceProvider.GetService <ApplicationDbContext>())
                    {
                        context.Database.Migrate();

                        // Initialize roles
                        ApplicationDbInitializer.SeedRoles(roleManager);
                        // Initialize users
                        ApplicationDbInitializer.SeedUsers(userManager);
                    }
                }
            }
            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.UseDatabaseErrorPage();
            app.UseRouting();

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

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });
        }
Example #6
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, MindOfSpaceContext mindOfSpaceContext, UserManager <Player> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            if (mindOfSpaceContext.Database.CanConnect())
            {
                mindOfSpaceContext.Database.Migrate();
            }
            else
            {
                mindOfSpaceContext.Database.Migrate();
                ApplicationDbInitializer.SeedRoles(mindOfSpaceContext);
                ApplicationDbInitializer.SeedUsers(userManager);
            }

            app.UseCors("AllowSetOrigins");


            app.UseHttpsRedirection();
            app.UseHsts();
            app.UseRouting();

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

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "MindOfSpace API");
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }