public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .Configure(app => { app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World!"); }); }); });
public static async Task Main(string[] args) { var host = Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartupIn this example, the ConfigureWebHostDefaults method is used to set up a basic web host configuration. We are using the UseStartup method to specify an instance of the Startup class, which is used to configure the application's services and middleware pipeline. Package Library: Microsoft.Extensions.Hosting, Microsoft.AspNetCore.Hosting.Abstractions.(); }) .Build(); await host.RunAsync(); }