启动

The UseStartup method on WebHostBuilder specifies the Startup class for your app.

WebHostBuilder 对象上的 UseStartup 方法明确指出了你的应用的 启动类。

  public class Program 
  { 
      public static void Main(string[] args) 
      { 
          var host = new WebHostBuilder() 
                      .UseKestrel() 
                      .UseStartup<Startup>() 
                      .Build();
          host.Run();
      }
  }

The Startup class is where you define the request handling pipeline and where any services needed by the app are configured. The Startup class must be public and contain the following methods:

启动类是你定义请求处理管道和所有应用配置的必需服务的地方。启动类必须是公开(public)的,并且必须包含以下方法:

  public class Startup 
  { 
      public void ConfigureServices(IServiceCollection services) { }
      public void Configure(IApplicationBuilder app) { }
  }
  • Configure Services defines the services (see Services below) used by your app (such as the ASP.NET MVC Core framework, Entity Framework Core, Identity, etc.)
  • Configure defines the middleware in the request pipeline
  • See Application Startup for more details
  • 配置和定义你的应用使用的服务(例如 ASP.NET MVC Core框架,Entity Framework Core,Identity等)
  • 配置并定义请求管道中的中间件
  • 查看 应用启动 来获取详情

results matching ""

    No results matching ""