// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ContextInitializer dbInitializer) { if (env.IsDevelopment()) { //If calling api and some exception occures, following will return html page string as response. So, in api this will not display exception page //app.UseDeveloperExceptionPage(); } else { //Use this if you want to redirect to error page form asp and not from angular app //app.UseExceptionHandler("/Error"); app.UseHsts(); } app.ConfigureExceptionHandler(Configuration, env); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(AppCommon.UserfilesFolderPath), RequestPath = AppCommon.UserfilesRequestName }); app.UseSpaStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { // To learn more about options for serving an Angular SPA from ASP.NET Core, // see https://go.microsoft.com/fwlink/?linkid=864501 spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } }); var isAutoMigrationOn = Convert.ToBoolean(Configuration["IsAutoMigrationOn"]); dbInitializer.InitDb(isAutoMigrationOn).Wait(); }