web analytics

ASP.NET Core Introduction

@2022-06-13 22:25:01

Services not created by the service container

Consider the following code:

public void ConfigureServices(IServiceCollection services)
    services.AddSingleton(new Service1());
    services.AddSingleton(new Service2());


In the preceding code:

  • The service instances aren't created by the service container.
  • The framework doesn't dispose of the services automatically.
  • The developer is responsible for disposing the services.


You must Sign In to comment on this topic.

© 2023 Digcode.com