Skip to content

Commit

Permalink
Modify WebAppStartup
Browse files Browse the repository at this point in the history
* WebAppStartup.ConfigureServices(WebApplicationBuilder);
* WebAppStartup.Configure(WebApplication);
  • Loading branch information
axunonb committed Dec 20, 2023
1 parent 873b4ea commit 4fe5d2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 2 additions & 7 deletions TournamentCalendar/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,9 @@ public static async Task Main(string[] args)
builder.Logging.AddNLog(nLogConfiguration, nLogOptions);
builder.Host.UseNLog();

builder.WebHost.ConfigureServices(WebAppStartup.ConfigureServices);

WebAppStartup.ConfigureServices(builder);
var app = builder.Build();

builder.WebHost.ConfigureAppConfiguration(_ =>
{
WebAppStartup.Configure(app, app.Services.GetRequiredService<ILoggerFactory>());
});
WebAppStartup.Configure(app);

await app.RunAsync();
}
Expand Down
9 changes: 7 additions & 2 deletions TournamentCalendar/WebAppStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ public static class WebAppStartup
/// <summary>
/// The method gets called by <see cref="Program"/> at startup, BEFORE building the app is completed.
/// </summary>
public static void ConfigureServices(WebHostBuilderContext context, IServiceCollection services)
public static void ConfigureServices(WebApplicationBuilder builder)
{
var services = builder.Services;
var context = new WebHostBuilderContext
{ Configuration = builder.Configuration, HostingEnvironment = builder.Environment };

#region * DataProtection service configuration *

// required for cookies and session cookies (will throw CryptographicException without)
Expand Down Expand Up @@ -199,9 +203,10 @@ private static void ConfigureLlblgenPro(IDbContext dbContext, IWebHostEnvironmen
/// <summary>
/// The method gets called by <see cref="Program"/> at startup, AFTER building the app is completed.
/// </summary>
public static void Configure(WebApplication app, ILoggerFactory loggerFactory)
public static void Configure(WebApplication app)
{
var env = app.Environment;
var loggerFactory = app.Services.GetRequiredService<ILoggerFactory>();
AppLogging.Configure(loggerFactory);

app.UseHttpsRedirection();
Expand Down

0 comments on commit 4fe5d2d

Please sign in to comment.