Skip to main content

Configure vs ConfigureServices in ASP.NET Core 2.0


Both words sound similar but there is a very thin line which differentiates these two. Let’s have a look at key differences between these two methods.


Configure
ConfigureServices
Main purpose
Does all the initial setup
Does service configurations
Default Location
Resides in Startup.cs
Resides in Startup.cs
Execution sequence
Hits prior to ConfigureServices
Hits after Configure
Ordering
Order of steps mentioned in this method matters
Order of the statements written to add services doesn’t matter
HTTP request
HTTP request first hits in this method
                                 -
Parameters
Configure(IApplicationBuilder app, IHostingEnvironment env)
ConfigureServices(IServiceCollection services)
Middleware
Setting up all the middleware are done in this method
                                 -
Services
 -           
All the required services are added in this method

Note: All the services which are added to IServiceCollection can be utilized across the application.

Comments