string Environment { get; }
Source
The current environment name. Read from command-line --environment
, "ASPNETCORE_ENVIRONMENT", or "DOTNET_ENVIRONMENT"; defaults to "Production" if none is set.
Default implementation of IEnvironmentProvider
that retrieves the environment from command-line host arguments or system environment variables. Command-line --environment
wins when supplied, otherwise it checks for "ASPNETCORE_ENVIRONMENT" first, then "DOTNET_ENVIRONMENT", and defaults to "Production" if neither is set. Can be overridden by passing a custom implementation to the StartupContext
, when building the host.
string? GetEnvironmentVariable(string name, string? defaultValue = null)
Gets the value of an environment variable from the system.
name
defaultValue
The environment variable value, an empty string when explicitly set empty, or the provided default if the variable is unset.
Use GetEnvironmentVariable
when callers need the provider's centralized lookup and unset-value defaulting behavior. Use Environment
or IsDevelopment
for the active application environment, and prefer direct System.Environment
access only for low-level infrastructure code. Passing a null or empty name
follows System.Environment.GetEnvironmentVariable(string)
semantics. Do not log returned values unless the variable is known to be non-sensitive, and do not trim or alter casing unless the caller intentionally wants to change the platform-specific value.
string? ResolveEnvironmentArgument(IReadOnlyList<string> args)
Resolves the effective command-line environment value from host arguments.
args
The last valid command-line environment value, or null
when none is supplied.
Recognizes split and inline forms such as --environment Development
and --environment=Development
. Blank, switch-like, or assignment-shaped split values are ignored, and the last valid command-line value wins to match Microsoft configuration duplicate-key behavior. Returns null
when the arguments do not contain a valid command-line environment value.
string Environment { get; }
Source
The current environment name. Read from command-line --environment
, "ASPNETCORE_ENVIRONMENT", or "DOTNET_ENVIRONMENT"; defaults to "Production" if none is set.
bool IsDevelopment { get; }
Source
True if the current environment is "Development".
A basic implementation of IAppSurfaceHostModule
that does nothing. This is useful for providing implementations of apps that do not require a module.
Use NoHostModule
only when no part of the application expects module-provided services, dependency registrations, middleware, endpoints, or host configuration. It is safe for minimal hosts that rely entirely on framework defaults. Create a real IAppSurfaceHostModule
when the app needs service registration, dependency wiring, or host lifecycle hooks.
void ConfigureServices(StartupContext context, IServiceCollection services)
Configures services for the module. This implementation is empty.
context
services
No services are added. Callers that expect module-owned services must not use NoHostModule
.
void RegisterDependentModules(ModuleDependencyBuilder builder)
Registers dependent modules. This implementation is empty.
builder
No dependencies are declared. Create a concrete module when startup ordering or dependency modules matter.
void ConfigureHostBeforeServices(StartupContext context, IHostBuilder builder)
Configures the host before services are registered. This implementation is empty.
context
builder
No host configuration is applied before service registration.
void ConfigureHostAfterServices(StartupContext context, IHostBuilder builder)
Configures the host after services are registered. This implementation is empty.
context
builder
No host configuration is applied after service registration.
Internal Services Registration