KestrunHost class

Provides hosting and configuration for the Kestrun application, including service registration, middleware setup, and runspace pool management.

public class KestrunHost : IDisposable

Public Members

name description
KestrunHost(…) Initializes a new instance of the KestrunHost class with the specified application name, root directory, and optional module paths. (2 constructors)
ApplicationName { get; } Gets the application name for the Kestrun host.
HostLogger { get; } Gets the Serilog logger instance used by the Kestrun host.
IsConfigured { get; } Indicates whether the Kestrun host configuration has been applied.
IsRunning { get; } Determines whether the Kestrun web application is currently running.
KestrunRoot { get; } Gets the root directory path for the Kestrun application.
Options { get; } Gets the configuration options for the Kestrun host.
RouteGroupStack { get; } Gets the stack used for managing route groups in the Kestrun host.
Scheduler { get; } Gets the scheduler service used for managing scheduled tasks in the Kestrun host.
AddControllers(…) Adds MVC / API controllers to the application.
AddFeature(…) Adds a feature configuration action to the feature queue. This action will be executed when the features are applied.
AddPowerShellRuntime(…) Adds a PowerShell runtime to the application. This middleware allows you to execute PowerShell scripts in response to HTTP requests.
AddScheduling(…) Adds a scheduling feature to the Kestrun host, optionally specifying the maximum number of runspaces for the scheduler.
AddService(…) Adds a service configuration action to the service queue. This action will be executed when the services are built.
AddSignalR<T>(…) Adds a SignalR hub to the application at the specified path.
Build() Builds the WebApplication. This method applies all queued services and middleware stages, and returns the built WebApplication instance.
ConfigureListener(…) Configures a listener for the Kestrun host with the specified port, optional IP address, certificate, protocols, and connection logging. (3 methods)
CreateRunspacePool(…) Creates and returns a new KestrunRunspacePoolManager instance with the specified maximum number of runspaces.
Dispose() Releases all resources used by the KestrunHost instance.
EnableConfiguration(…) Applies the configured options to the Kestrel server and initializes the runspace pool.
Run() Runs the Kestrun web application, applying configuration and starting the server.
StartAsync(…) Starts the Kestrun web application asynchronously.
Stop() Initiates a graceful shutdown of the Kestrun web application.
StopAsync(…) Stops the Kestrun web application asynchronously.
Use(…) Adds a middleware stage to the application pipeline.

See Also