Microsoft.Extensions.Hosting.Abstractions

Namespace: Microsoft.Extensions.Hosting.Abstractions
Assembly: Microsoft.Extensions.Hosting.Abstractions.dll

Interfaces

IHost

Represents a host that is configured and ready to execute.

public interface IHost : IDisposable

Contains members for starting, stopping, and managing the lifecycle of the host.

IHostBuilder

Used to configure application services and host.

public interface IHostBuilder

Provides methods to configure the application's services, host settings, and build the actual host.

IHostEnvironment

Provides information about the environment the application is running in.

public interface IHostEnvironment
  • string EnvironmentName: Gets the name of the environment the application is running in.
  • string ApplicationName: Gets the name of the application.
  • string ContentRootPath: Gets the absolute path to the directory that contains the application content files.
  • IFileProvider ContentRootFileProvider: Gets an IFileProvider representing the content root.

IHostLifetime

Represents the lifetime of the host.

public interface IHostLifetime

Responsible for managing the startup and shutdown of the host.

Classes

Host

A default implementation of IHost.

public class Host : IHost

Provides the core functionality for hosting an application.

HostBuilder

A default implementation of IHostBuilder.

public class HostBuilder : IHostBuilder

Configures and builds an IHost instance.

GenericHostEnvironment

A generic implementation of IHostEnvironment.

public class GenericHostEnvironment : IHostEnvironment

Provides a concrete implementation for host environment details.

Extensions

HostConfigurationBuilderExtensions

Extension methods for configuring the host builder.

public static class HostConfigurationBuilderExtensions

Provides methods like ConfigureHostConfiguration and UseContentRoot.

HostExtensions

Extension methods for configuring the host.

public static class HostExtensions

Includes methods such as Run, Start, and StopAsync.

HostBuilderContextExtensions

Extension methods for accessing IHostBuilderContext.

public static class HostBuilderContextExtensions

Provides utility to get host builder context information.