Beispiel #1
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services    = scope.ServiceProvider;
                var context     = services.GetRequiredService <AdsContext>();
                var userManager = services.GetRequiredService <UserManager <ApplicationUser> >();
                SeedRoles.SeedAsync(context).Wait();
                SeedAdminUser.SeedAsync(context, userManager).Wait();
            }

            host.Run();
        }
Beispiel #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, SeedAdminUser seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseAuthentication();
            app.UseCors(opt => opt.WithOrigins("http://localhost:4200").AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod());
            seeder.SeedData();
            //app.UseHttpsRedirection();
            app.UseDefaultFiles();
            app.UseStaticFiles();
            //app.UseMvc();
            app.UseMvc(routes =>
            {
                routes.MapSpaFallbackRoute(
                    name: "spa-fallback",
                    defaults: new { controller = "fallback", action = "Index" });
            });
        }