Example #1
0
        public static async Task Main(string[] args)
        {
            var build = CustomWebHostBuilder.Create <Startup>(args).Build();

            try
            {
                await build.RunAsync();
            }
            finally
            {
                await build.StopAsync();
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            var build  = CustomWebHostBuilder.Create <Startup>(CustomWebHostBuilder.AppCommonRoutingFileSettings, args).Build();
            var logger = (ILogger <IWebHost>)build.Services.GetService(typeof(ILogger <IWebHost>));

            try
            {
                logger.LogInformation($"{nameof(Main)}: build running...");
                build.Run();
            }
            catch (Exception ex)
            {
                logger.LogError("Fatal Error", ex);
                throw;
            }
            finally
            {
                logger.LogInformation($"{nameof(Main)}: build stopping...");
                build.StopAsync();
            }
        }