// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime appLifetime) { // loggerFactory.AddConsole(Configuration.GetSection("Logging")); // loggerFactory.AddDebug(); app.UseCors(builder => builder.WithOrigins("http://localhost:4200") .AllowAnyMethod() .AllowAnyHeader()); JwtSettings = app.ApplicationServices.GetService <JwtSettings>(); var generalSettings = app.ApplicationServices.GetService <GeneralSettings>(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } if (generalSettings.SeedData) { var dataInitializer = app.ApplicationServices.GetService <IDataInitializer>(); dataInitializer.SeedAsync(); } app.UseAuthentication(); app.UseMyExceptionMiddleware(); MongoConfigurator.Initiaize(); app.UseMvc(); appLifetime.ApplicationStopped.Register(() => ApplicationContainer.Dispose()); }