web analytics

ASP.NET Core Introduction

Options
@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());

    services.AddRazorPages();
}

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.

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com