// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (HostingEnvironmentExtensions.IsDevelopment(env)) { app.UseDeveloperExceptionPage(); } else { 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(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (HostingEnvironmentExtensions.IsDevelopment(env)) { DeveloperExceptionPageExtensions.UseDeveloperExceptionPage(app); } else { HstsBuilderExtensions.UseHsts(app); } MvcApplicationBuilderExtensions.UseMvc(app); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseStatusCodePages(); app.UseAuthentication(); if (HostingEnvironmentExtensions.IsDevelopment(env)) { DeveloperExceptionPageExtensions.UseDeveloperExceptionPage(app); } MvcApplicationBuilderExtensions.UseMvc(app); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (HostingEnvironmentExtensions.IsDevelopment(env)) { DeveloperExceptionPageExtensions.UseDeveloperExceptionPage(app); } else { ExceptionHandlerExtensions.UseExceptionHandler(app, "/Error"); HstsBuilderExtensions.UseHsts(app); } HttpsPolicyBuilderExtensions.UseHttpsRedirection(app); StaticFileExtensions.UseStaticFiles(app); MvcApplicationBuilderExtensions.UseMvc(app); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { // Invoking as extension methods if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); // Compliant app.UseDatabaseErrorPage(); // Compliant } // Invoking as static methods if (HostingEnvironmentExtensions.IsDevelopment(env)) { DeveloperExceptionPageExtensions.UseDeveloperExceptionPage(app); // Compliant DatabaseErrorPageExtensions.UseDatabaseErrorPage(app); // Compliant } // Not in development if (!env.IsDevelopment()) { DeveloperExceptionPageExtensions.UseDeveloperExceptionPage(app); // Noncompliant DatabaseErrorPageExtensions.UseDatabaseErrorPage(app); // Noncompliant } // Custom conditions are deliberately ignored var isDevelopment = env.IsDevelopment(); if (isDevelopment) { app.UseDeveloperExceptionPage(); // Noncompliant, False Positive app.UseDatabaseErrorPage(); // Noncompliant, False Positive } // Only simple IF checks are considered while (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); // Noncompliant FP app.UseDatabaseErrorPage(); // Noncompliant FP break; } // These are called unconditionally app.UseDeveloperExceptionPage(); // Noncompliant app.UseDatabaseErrorPage(); // Noncompliant DeveloperExceptionPageExtensions.UseDeveloperExceptionPage(app); // Noncompliant DatabaseErrorPageExtensions.UseDatabaseErrorPage(app); // Noncompliant }