Friday, May 5, 2023

What is the role of ConfigureServices and Configure method?

► ConfigureServices method is optional and defined inside startup class.

► It takes care of registering services that are consumed across the application using Dependency Injection (DI) or Application Services.

► It's get called by host before 'Configure' method to configure the app's services.

►  Configure method is used to add middleware components to IApplication Builder instance that's available in Configure method.

► It accepts IApplication Builder as a parameter and also it has two optional parameters: IHostingEnvironment and ILoggerFactory.

► Using this method, we can configure built-in middleware such as routing, authentication, session, etc. as well as third-party middleware.

► Configure method also specify how the app respond to HTTP request and response.