// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider, ILoggerFactory loggerFactory) { loggerFactory.AddNLog(); //add NLog.Web app.AddNLogWeb(); app.UseRequestIPMiddleware(); ClientAppPath = Path.Combine(Directory.GetCurrentDirectory(), ClientAppPath); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true, ProjectPath = ClientAppPath, ConfigFile = $"{ClientAppPath}webpack.config.js", HotModuleReplacementEndpoint = "/dist/__webpack_hmr" }); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); // Seed the database with the sample applications. // Note: in a real world application, this step should be part of a setup script. InitializeAsync(app.ApplicationServices, CancellationToken.None).GetAwaiter().GetResult(); if (env.IsDevelopment()) { // init roles and users etc DBInitilizer.Initialize(serviceProvider); GroupsInit.Initialize(serviceProvider); FileCategoriesInit.Initialize(serviceProvider); } app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider, ILoggerFactory loggerFactory) { loggerFactory.AddNLog(); app.UseServerSentEventsMiddleware(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware( new WebpackDevMiddlewareOptions { HotModuleReplacement = true, ConfigFile = "./build/webpack.config.js" }); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseResponseCompression(); // No need if you use IIS, but really something good for Kestrel! app.UseAuthentication(); // Seed the database with the sample applications. // Note: in a real world application, this step should be part of a setup script. InitializeAsync(app.ApplicationServices, CancellationToken.None).GetAwaiter().GetResult(); if (env.IsDevelopment()) { // init roles and users etc DBInitilizer.Initialize(serviceProvider); GroupsInit.Initialize(serviceProvider); FileCategoriesInit.Initialize(serviceProvider); } // Idea: https://code.msdn.microsoft.com/How-to-fix-the-routing-225ac90f // This avoid having a real mvc view. You have other way of doing, but this one works // properly. app.UseSpa(); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseMvc(); }