File tree Expand file tree Collapse file tree
ProjectTemplates/ReferenceProject Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,9 +26,9 @@ public class ExceptionMiddleware
2626 {
2727 RequestDelegate Next { get ; }
2828 ILogger Logger { get ; }
29- IWebHostEnvironment Environment { get ; }
29+ IHostEnvironment Environment { get ; }
3030
31- public ExceptionMiddleware ( RequestDelegate next , ILogger < ExceptionMiddleware > logger , IWebHostEnvironment environment )
31+ public ExceptionMiddleware ( RequestDelegate next , ILogger < ExceptionMiddleware > logger , IHostEnvironment environment )
3232 {
3333 Environment = environment ?? throw new ArgumentNullException ( nameof ( environment ) ) ;
3434 Logger = logger ?? throw new ArgumentNullException ( nameof ( logger ) ) ;
Original file line number Diff line number Diff line change 44using Microsoft . Extensions . Logging ;
55using Microsoft . Extensions . Configuration ;
66using Serilog ;
7+ using Microsoft . Extensions . Hosting ;
78
89namespace ReferenceProject
910{
@@ -14,10 +15,9 @@ public static void Main(string[] args)
1415 CreateHostBuilder ( args ) . Build ( ) . Run ( ) ;
1516 }
1617
17- // TODO: WebHost -> Host: https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio#hostbuilder-replaces-webhostbuilder
18- public static IWebHostBuilder CreateHostBuilder ( string [ ] args ) =>
19- WebHost . CreateDefaultBuilder ( args )
20- . ConfigureServices ( services => services . AddAutofac ( ) )
18+ public static IHostBuilder CreateHostBuilder ( string [ ] args ) =>
19+ Host . CreateDefaultBuilder ( args )
20+ . UseServiceProviderFactory ( new AutofacServiceProviderFactory ( ) )
2121 . ConfigureLogging ( ( context , logging ) =>
2222 {
2323 logging . ClearProviders ( ) ;
@@ -38,6 +38,9 @@ public static IWebHostBuilder CreateHostBuilder(string[] args) =>
3838 {
3939 x . AddEnvironmentVariables ( ) ;
4040 } )
41- . UseStartup < Startup > ( ) ;
41+ . ConfigureWebHostDefaults ( webBuilder =>
42+ {
43+ webBuilder . UseStartup < Startup > ( ) ;
44+ } ) ;
4245 }
4346}
Original file line number Diff line number Diff line change @@ -28,11 +28,8 @@ namespace ReferenceProject
2828{
2929 public class Startup
3030 {
31- ILogger < Startup > Logger { get ; }
32-
33- public Startup ( IConfiguration configuration , IWebHostEnvironment env , ILogger < Startup > logger )
31+ public Startup ( IConfiguration configuration , IHostEnvironment env )
3432 {
35- Logger = logger ;
3633 Startup . Configuration = configuration ;
3734
3835 // https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#using-environment-variables-in-configuration-options
@@ -144,7 +141,7 @@ public void ConfigureProductionContainer(ContainerBuilder builder)
144141 }
145142
146143 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
147- public void Configure ( IApplicationBuilder app )
144+ public void Configure ( IApplicationBuilder app , ILogger < Startup > logger )
148145 {
149146 // Use an exception handler middleware before any other handlers
150147 // See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#unhandled-exceptions-handling
@@ -168,7 +165,7 @@ public void Configure(IApplicationBuilder app)
168165 endpoints . MapHealthChecks ( Constants . Health . EndPoint ) ; // TODO: Must be documented: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-3.1
169166 } ) ;
170167
171- Logger . LogInformation ( "Server started " ) ;
168+ logger . LogInformation ( "Server configuration is completed " ) ;
172169 }
173170 }
174171}
You can’t perform that action at this time.
0 commit comments