What is the difference between ConfigureServices and Configure methods?

  • ConfigureServices() and Configure() methods are used to register services and configure components within the request pipeline respectively.
  • ConfigureServices() takes a parameter of type IServiceCollection.
  • Configure() takes a parameter of type IApplicationBuilder with possible parameters of any Service which is registered in the ConfigureServices() method.
  • an application should contain an ConfigureServices() method with an optional Configure() method.
public class Startup
{
    public void ConfigureServices(IServiceCollection services) 
    {
    }
    public void Configure(IApplicationBuilder app)
    {
    }
}

ASP.NET Core Posted Apr 06, 2020

You can now show your support. 😊

We use cookies to provide you with a great user experience, analyze traffic and serve targeted promotions.   Learn More   Accept