diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index cce2c2b96..a85e7ddc0 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -49,17 +49,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API { RegisterAppInsights(services); - // Add framework services. - //services.AddMvc(options => - // { - // options.Filters.Add(typeof(HttpGlobalExceptionFilter)); - // options.Filters.Add(typeof(ValidateModelStateFilter)); - - // }) - // .AddNewtonsoftJson() - // .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) - // .AddControllersAsServices(); - services.AddControllers(options => { options.Filters.Add(typeof(HttpGlobalExceptionFilter)); @@ -204,10 +193,12 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API ConfigureAuth(app); + app.UseAuthorization(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); + endpoints.MapControllers(); endpoints.MapHealthChecks("/hc", new HealthCheckOptions() { Predicate = _ => true, diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs index 5e96f90d8..2a5f2bfb8 100644 --- a/src/Services/Catalog/Catalog.API/Startup.cs +++ b/src/Services/Catalog/Catalog.API/Startup.cs @@ -55,8 +55,6 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API .AddSwagger() .AddCustomHealthCheck(Configuration); - services.AddControllers(); - var container = new ContainerBuilder(); container.Populate(services); @@ -139,11 +137,13 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API public static IServiceCollection AddCustomMVC(this IServiceCollection services, IConfiguration configuration) { services.AddMvc(options => - { - options.Filters.Add(typeof(HttpGlobalExceptionFilter)); - }) - .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) - .AddControllersAsServices(); + { + options.Filters.Add(typeof(HttpGlobalExceptionFilter)); + }) + .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) + .AddControllersAsServices(); + + services.AddControllers(); services.AddCors(options => { diff --git a/src/Services/Location/Locations.API/Startup.cs b/src/Services/Location/Locations.API/Startup.cs index d71f05d60..2199157c8 100644 --- a/src/Services/Location/Locations.API/Startup.cs +++ b/src/Services/Location/Locations.API/Startup.cs @@ -51,7 +51,11 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddControllersAsServices(); - services.AddControllers(); + services.AddControllers(options => + { + options.Filters.Add(typeof(HttpGlobalExceptionFilter)); + + }).AddNewtonsoftJson(); ConfigureAuthService(services); diff --git a/src/Services/Marketing/Marketing.API/Startup.cs b/src/Services/Marketing/Marketing.API/Startup.cs index 24064d3a3..5fc3c60d3 100644 --- a/src/Services/Marketing/Marketing.API/Startup.cs +++ b/src/Services/Marketing/Marketing.API/Startup.cs @@ -23,7 +23,6 @@ using Marketing.API.IntegrationEvents.Handlers; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Diagnostics.HealthChecks; - using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Middlewares; using Microsoft.Extensions.Diagnostics.HealthChecks; @@ -50,15 +49,7 @@ RegisterAppInsights(services); // Add framework services. - services - .AddCustomHealthCheck(Configuration) - .AddMvc(options => - { - options.Filters.Add(typeof(HttpGlobalExceptionFilter)); - }) - .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) - .AddControllersAsServices(); //Injecting Controllers themselves thru DIFor further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services - + services.AddCustomHealthCheck(Configuration); services.AddControllers(); services.Configure(Configuration); @@ -198,10 +189,12 @@ ConfigureAuth(app); + app.UseAuthorization(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); + endpoints.MapControllers(); endpoints.MapHealthChecks("/hc", new HealthCheckOptions() { Predicate = _ => true, diff --git a/src/_build/dependencies.props b/src/_build/dependencies.props index 04704261e..5dc91f6ec 100644 --- a/src/_build/dependencies.props +++ b/src/_build/dependencies.props @@ -72,7 +72,7 @@ 3.0.0-preview7.19362.6 3.0.0-preview7.19362.6 3.0.0-preview7.19365.7 - 2.2.0 + 3.0.0-preview7.19362.4 2.2.0 2.2.0 2.2.0