// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseDeveloperExceptionPage(); //app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } var appSession = new AppSession(env); UpdateDatabase(app); //Run Migration WebHelpers.Configure(app.ApplicationServices.GetRequiredService <IHttpContextAccessor>()); app.UseRequestLocalization(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseSession(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), "ViewCore")), RequestPath = "/ViewCore" }); app.UseRouting(); app.UseSession(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Login}/{action=Login}/{id?}"); }); WebHelpers.Configure(app.ApplicationServices.GetRequiredService <IHttpContextAccessor>()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseDeveloperExceptionPage(); //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(); } UpdateDatabase(app); //Run Migration app.UseSignalR(routes => { routes.MapHub <NotificationHub>("/NotificationHub"); }); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSession(); WebHelpers.Configure(app.ApplicationServices.GetRequiredService <IHttpContextAccessor>()); app.UseRequestLocalization(); app.UseHttpsRedirection(); app.UseStaticFiles(); //app.UseCookiePolicy(); app.UseAuthentication(); app.UseSwagger(); // Enable middleware to serve generated Swagger as a JSON endpoint. // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. //Swagger API documentation app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "sal7lyAdmin API V1"); c.SwaggerEndpoint("/swagger/v2/swagger.json", "sal7lyAdmin API V2"); }); //app.UseEndpoints(endpoints => //{ // endpoints.MapRazorPages(); //}); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Account}/{action=Login}/{id?}"); }); ThreadStart starter = delegate { startProcess(app); }; Thread tr = new Thread(starter); tr.IsBackground = true; tr.Start(); }
// 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseCors("AllowCors"); ConfigureAuth(app); app.UseApplicationInsightsRequestTelemetry(); app.UseApplicationInsightsExceptionTelemetry(); MapExceptionTypes(app); app.UseMvc(); WebHelpers.Configure(app.ApplicationServices.GetRequiredService <IHttpContextAccessor>()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataContext dataContext) { // dataContext.Database.EnsureDeleted(); // migrate any database changes on startup (includes initial db creation) //dataContext.Database.EnsureCreated(); dataContext.Database.Migrate(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseOpenApi(); app.UseSwaggerUi3(); app.UseReDoc(options => { options.Path = "/redoc"; options.DocumentPath = "/swagger/swagger/swagger.json"; }); app.UseReDoc(options => { options.Path = "/openapi_redoc"; options.DocumentPath = "/swagger/openapi/swagger.json"; }); app.UseRouting(); app.UseCors("AllowAllOrigins"); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapHub <PostHub>("/PostHub"); }); app.UseMvc(); //app.UseMvc(routeBuilder => //{ // routeBuilder.EnableDependencyInjection(); // routeBuilder.Expand().Select().Filter().Count().OrderBy(); //}); WebHelpers.Configure(app.ApplicationServices.GetRequiredService <IHttpContextAccessor>()); }
// 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseCors("AllowCors"); ConfigureAuth(app); app.UseApplicationInsightsRequestTelemetry(); app.UseApplicationInsightsExceptionTelemetry(); MapExceptionTypes(app); app.UseMvc(routes => { routes.MapRoute("default", "{controller=UnitManager}/{action=Get}/{id?}"); }); WebHelpers.Configure(app.ApplicationServices.GetRequiredService <IHttpContextAccessor>()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { // routes.MapRoute( name: "mchi_tiet", template: "m.{TypeName}/{Alias}/{ID}.html", defaults: new { controller = "mtinnhanh247", action = "chitiet" }); routes.MapRoute( name: "mdanh_muc", template: "m.{Alias}-{ID}.html", defaults: new { controller = "mtinnhanh247", action = "danhmuc" }); routes.MapRoute( name: "mdefault", template: "{controller=mtinnhanh247}/{action=trangchu}"); routes.MapRoute( name: "chi_tiet", template: "{TypeName}/{Alias}/{ID}.html", defaults: new { controller = "tinnhanh247", action = "chitiet" }); routes.MapRoute( name: "danh_muc", template: "{Alias}-{ID}.html", defaults: new { controller = "tinnhanh247", action = "danhmuc" }); routes.MapRoute( name: "default", template: "{controller=tinnhanh247}/{action=trangchu}"); }); WebHelpers.Configure(app.ApplicationServices.GetRequiredService <IHttpContextAccessor>()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true, ProjectPath = Path.Combine(Directory.GetCurrentDirectory(), "client"), ConfigFile = Path.Combine(Directory.GetCurrentDirectory(), "client/webpack.config.js") }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), @"client/src/statics")), RequestPath = new PathString("/statics") }); WebHelpers.Configure(app.ApplicationServices.GetRequiredService <IHttpContextAccessor>()); } app.UseMvc(); }
// 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true, ProjectPath = Path.Combine(Directory.GetCurrentDirectory(), "client"), ConfigFile = Path.Combine(Directory.GetCurrentDirectory(), "client/webpack.config.js") }); } else { app.UseDefaultFiles(); app.UseStaticFiles(); } WebHelpers.Configure(app.ApplicationServices.GetRequiredService <IHttpContextAccessor>()); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public static void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCustomSerilogRequestLogging(); app.UseRouting(); app.UseStaticFiles(); if (!Directory.Exists("./Images")) { Directory.CreateDirectory("./Images"); } app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider( Path.Combine(env.ContentRootPath, "Images")), RequestPath = "/Images" }); app.UseDirectoryBrowser(new DirectoryBrowserOptions { FileProvider = new PhysicalFileProvider( Path.Combine(env.ContentRootPath, "Images")), RequestPath = "/Images" }); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider( Path.Combine(env.ContentRootPath, "Documents")), RequestPath = "/Documents" }); app.UseDirectoryBrowser(new DirectoryBrowserOptions { FileProvider = new PhysicalFileProvider( Path.Combine(env.ContentRootPath, "Documents")), RequestPath = "/Documents" }); app.UseCors("AllowAll"); app.UseApiDoc(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); WebHelpers.Configure(app.ApplicationServices.GetRequiredService <IHttpContextAccessor>()); //added request logging app.UseHttpsRedirection(); app.UseMiddleware <JwtMiddleware>(); app.UseMiddleware <ApiLoggingMiddleware>(); app.UseResponseCompression(); app.UseAuthentication(); app.UseAuthorization(); app.UseSecureHeadersMiddleware(SecureHeadersMiddlewareExtensions.BuildDefaultConfiguration()); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); // app.UseCors(options => options.AllowAnyOrigin()); }