EndpointHostHelpers Methods
ClassMethods9 members
Provides helper methods for validating localhost addresses and for resolving endpoint URLs against a configured target host.
GetUrlWithTargetHostAsync(EndpointReference, CancellationToken)Section titled GetUrlWithTargetHostAsync(EndpointReference, CancellationToken)staticValueTask<string?> Gets the URL of the endpoint, adjusting for localhost TLD if configured.
public static class EndpointHostHelpers{ public static ValueTask<string?> GetUrlWithTargetHostAsync( EndpointReference endpoint, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
endpointEndpointReferenceThe endpoint reference.cancellationTokenCancellationTokenoptionalA cancellation token.Returns
ValueTask<string?>The URL with the appropriate hostname.Exceptions
ArgumentNullExceptionThrown when endpoint is null.Remarks
When the endpoint's
EndpointAnnotation.TargetHost is a localhost TLD (e.g., aspire-dashboard.dev.localhost), the allocated endpoint address will be "localhost" since that's what the service actually binds to. This method returns the URL with the configured TLD hostname instead, which is what users expect to see and use in browsers. Determines whether the specified host ends with ".dev.localhost".
public static class EndpointHostHelpers{ public static bool IsDevLocalhostTld( string? host) { // ... }}Parameters
hoststring?The host to check.Returns
booltrue if the host ends with ".dev.localhost" (case-insensitive); otherwise, false. Determines whether the specified URI uses a host that ends with ".dev.localhost".
public static class EndpointHostHelpers{ public static bool IsDevLocalhostTld( Uri? uri) { // ... }}Parameters
uriUri?The URI to check.Returns
booltrue if the host ends with ".dev.localhost" (case-insensitive); otherwise, false. Determines whether the specified host is "localhost".
public static class EndpointHostHelpers{ public static bool IsLocalhost( string? host) { // ... }}Parameters
hoststring?The host to check.Returns
booltrue if the host is "localhost" (case-insensitive); otherwise, false. Determines whether the specified URI uses a host that is "localhost".
public static class EndpointHostHelpers{ public static bool IsLocalhost( Uri? uri) { // ... }}Parameters
uriUri?The URI to check.Returns
booltrue if the host is "localhost" (case-insensitive); otherwise, false. Determines whether the specified host is "localhost" or uses the ".localhost" top-level domain.
public static class EndpointHostHelpers{ public static bool IsLocalhostOrLocalhostTld( string? host) { // ... }}Parameters
hoststring?The host to check.Returns
booltrue if the host is "localhost" (case-insensitive) or ends with ".localhost" (case-insensitive); otherwise, false. Determines whether the specified URI uses a host that is "localhost" or ends with ".localhost".
public static class EndpointHostHelpers{ public static bool IsLocalhostOrLocalhostTld( Uri? uri) { // ... }}Parameters
uriUri?Returns
booltrue if the host is "localhost" (case-insensitive) or ends with ".localhost" (case-insensitive); otherwise, false. Determines whether the specified host ends with ".localhost".
public static class EndpointHostHelpers{ public static bool IsLocalhostTld( string? host) { // ... }}Parameters
hoststring?The host to check.Returns
booltrue if the host ends with ".localhost" (case-insensitive); otherwise, false. Determines whether the specified URI uses a host that is "localhost".
public static class EndpointHostHelpers{ public static bool IsLocalhostTld( Uri? uri) { // ... }}Parameters
uriUri?The URI to check.Returns
booltrue if the host ends with ".localhost" (case-insensitive); otherwise, false.