Created
September 24, 2020 13:39
-
-
Save ssukhpinder/efcd403c4946b8e25343c3cebf0a0774 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
CreateHostBuilder(args).Build().Run(); | |
} | |
public static IHostBuilder CreateHostBuilder(string[] args) => | |
Host.CreateDefaultBuilder(args) | |
.ConfigureAppConfiguration((hostingContext, config) => | |
{ | |
}) | |
.ConfigureWebHostDefaults(webBuilder => | |
{ | |
webBuilder.ConfigureServices(services => | |
{ | |
services.AddControllersWithViews(); | |
}) | |
.Configure(app => | |
{ | |
var loggerFactory = app.ApplicationServices | |
.GetRequiredService<ILoggerFactory>(); | |
var logger = loggerFactory.CreateLogger<Program>(); | |
var env = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>(); | |
var config = app.ApplicationServices.GetRequiredService<IConfiguration>(); | |
logger.LogInformation("Logged in Configure"); | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
else | |
{ | |
app.UseExceptionHandler("/Home/Error"); | |
app.UseHsts(); | |
} | |
var configValue = config["MyConfigKey"]; | |
}); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment