ASP NET Core Creates a HelloWorld sample WebApp

    0

    42

    lucycodes42

    C# recipes

    The code in this file creates and runs a program that uses the WebHost class. The WebHost class provides a Builder class that you can use to create an instance of the WebHost class. The first line of the code creates a new instance of the WebHost class and passes it the string[] args as its argument. The second line of the code uses the UseStartup method on the WebHost class to call the Startup class. The Startup class is a class that you can use to configure and start your application.

    The first thing that the Startup class does is call the Build method on the WebHost class. The Build method creates a new instance of the Program class and uses the arguments that you passed to the constructor of the WebHost class. The code in the Main method calls the Build method on the WebHost class and then uses the Run method on the Program class to run the application.

    Shortcut: ac_helloworld_web_app

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.Logging;
    
    namespace WebApp
    {
      public class Program
      {
        public static void Main(string[] args)
        {
          BuildWebHost(args).Run();
        }
    
        public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
          .UseStartup<Startup>()
          .Build();
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.