// 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(); } if (env.IsProduction() || env.IsStaging() || env.IsEnvironment("Staging_2")) { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseHttpsRedirection(); app.UseRouting(); SwaggerConfig.Configure(app, Configuration); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { CORSConfig.Configure(app); Authentication.Configure(app); app.UseMvc(); SwaggerConfig.Configure(app); }
// 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(); //app.UseDatabaseErrorPage(); } else { app.UseHsts(); app.UseExceptionHandler("/Home/Error"); } _swagger.Configure(app, env); app.UseStaticFiles(); app.UseRouting(); //app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{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) { app.UseExceptionHandler(new ExceptionHandlerOptions() { ExceptionHandler = async context => { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; var ex = context.Features.Get <IExceptionHandlerFeature>()?.Error; if (ex == null) { return; } var error = new { message = ex.Message, detail = ex.StackTrace }; context.Response.ContentType = "application/json"; using (var writer = new StreamWriter(context.Response.Body)) { new JsonSerializer().Serialize(writer, error); await writer.FlushAsync().ConfigureAwait(false); } } }); using (var scope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { var provider = scope.ServiceProvider; using (var dbContext = provider.GetRequiredService <DataContext>()) { dbContext.Seed(); } } app.UseCors(builder => builder.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod().AllowCredentials()); JwtConfig.Configure(app, this.AuthConfiguration); app.UseStaticFiles(); app.UseMvc(); //Configure Swagger SwaggerConfig.Configure(app, this.SwaggerConfiguration, this.AuthConfiguration); //Configure ServiceBusQueue if (this.ServiceBusQueueConfiguration?.IsEnabled == true) { ServiceBusQueueConfig.Configure(app); } }
/// <summary> /// /// </summary> /// <param name="app"></param> public void Configuration(IAppBuilder app) { HttpConfiguration config = new HttpConfiguration(); RouteConfig.Configure(config); FormatterConfig.Configure(config); SwaggerConfig.Configure(config); app.UseWebApi(config); }
// Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { // Configure the HTTP request pipeline. app.UseStaticFiles(); // Add MVC to the request pipeline. app.UseMvc(); SwaggerConfig.Configure(app, env); }
// 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.UseMvc(); SwaggerConfig.Configure(app, env); }
// 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.UseHsts(); } _swagger.Configure(app, env); app.UseMvcWithDefaultRoute(); }
// 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.UseHsts(); } SwaggerConfig.Configure(app, env); app.UseHttpsRedirection(); app.UseMvc(); }
public static HttpConfiguration Build(Container container) { var configuration = new HttpConfiguration(); FormatterConfig.Configure(configuration); SwaggerConfig.Configure(configuration); container.RegisterWebApiControllers(configuration, Assembly.GetExecutingAssembly(), typeof(IpAdressesController).Assembly); container.EnableHttpRequestMessageTracking(configuration); configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container); configuration.MapHttpAttributeRoutes(); container.Verify(); return(configuration); }
/// <summary> /// Specifies how the ASP.NET application will respond to individual HTTP request. /// </summary> /// <param name="app">Instance of <see cref="IAppBuilder"/>.</param> public void Configuration(IAppBuilder app) { CorsConfig.ConfigureCors(ConfigurationManager.AppSettings["cors"]); app.UseCors(CorsConfig.Options); var configuration = new HttpConfiguration(); AutofacConfig.Configure(configuration); app.UseAutofacMiddleware(AutofacConfig.Container); FormatterConfig.Configure(configuration); RouteConfig.Configure(configuration); ServiceConfig.Configure(configuration); SwaggerConfig.Configure(configuration); app.UseWebApi(configuration); }
// 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(); } SwaggerConfig.Configure(app); app.UseHttpsRedirection(); app.UseRouting(); app.UseCors(MyCors); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// 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(); } // global error handler app.UseMiddleware <ErrorHandlingMiddleware>(); app.UseHttpsRedirection(); JwtConfig.Configure(app, this.AuthConfiguration); // Configure Swagger SwaggerConfig.Configure(app, this.SwaggerConfiguration, this.AuthConfiguration, this.ApiMetadata); // CORS app.UseCors(builder => builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); app.UseRouting(); if (this.AuthConfiguration?.IsEnabled == true) { app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers() .RequireAuthorization(); }); } else { app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider) { ErrorHandlerConfig.Configure(app, env); app.UseHttpsRedirection(); app.UseRouting(); CorsConfig.Configure(app, env); AuthConfig.Configure(app, env); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); SwaggerConfig.Configure(app, env, provider); }
/// <summary> /// Specifies how the ASP.NET application will respond to individual HTTP request. /// </summary> /// <param name="app">Instance of <see cref="IAppBuilder"/>.</param> public void Configuration(IAppBuilder app) { LogConfig.Configure(); app.UseRequestLogging(); CorsConfig.ConfigureCors(ConfigurationManager.AppSettings["cors"]); app.UseCors(CorsConfig.Options); HttpConfiguration configuration = new HttpConfiguration(); FormatterConfig.Configure(configuration); RouteConfig.Configure(configuration); ServiceConfig.Configure(configuration); SwaggerConfig.Configure(configuration); app.UseWebApi(configuration); MappingProfile map = new MappingProfile(); map.Iniciar(); }
/// <summary> /// Configures the application using the provided builder, hosting environment, and logging factory. /// </summary> /// <param name="app">The current application builder.</param> /// <param name="env">The current hosting environment.</param> /// <param name="loggerFactory">The logging factory used for instrumentation.</param> /// <param name="provider">The API version descriptor provider used to enumerate defined API versions.</param> public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApiVersionDescriptionProvider provider) { loggerFactory.AddConsole(this.Configuration.GetSection("Logging")); loggerFactory.AddFile(this.Configuration.GetSection("Logging").GetValue <string>("PathFormat"), isJson: true); if (env.IsDevelopment() || Program.IsLocal(env)) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } // Custom Configuration LocalizationConfig.Configure(app); SwaggerConfig.Configure(app, provider); app.UseHttpsRedirection(); app.UseMvc(); }
private void InitSwagger(IServiceCollection services) { services .AddSwaggerGen(o => SwaggerConfig.Configure(o, Configuration)); }
protected virtual void ConfigureSwagger(IContainer container) { SwaggerConfig.Configure(HttpConfiguration, GetType(), Settings.Hosting.AuthenticationRequired); }