# EndpointReference Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [EndpointReference](/reference/api/csharp/aspire.hosting/endpointreference.md)
- Kind: `Methods`
- Members: `4`

Represents an endpoint reference for a resource with endpoints.

## GetTlsValue(ReferenceExpression, ReferenceExpression)

- Name: `GetTlsValue(ReferenceExpression, ReferenceExpression)`
- Returns: [ReferenceExpression](/reference/api/csharp/aspire.hosting/referenceexpression.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L164-L168)

Creates a conditional [ReferenceExpression](/reference/api/csharp/aspire.hosting/referenceexpression.md) that resolves to `enabledValue` when [EndpointAnnotation.TlsEnabled](/reference/api/csharp/aspire.hosting/endpointannotation/properties.md#tlsenabled) is `true` on this endpoint, or to `disabledValue` otherwise.

```csharp
public sealed class EndpointReference
{
    public ReferenceExpression GetTlsValue(
        ReferenceExpression enabledValue,
        ReferenceExpression disabledValue)
    {
        // ...
    }
}
```

## Parameters

- `enabledValue` ([ReferenceExpression](/reference/api/csharp/aspire.hosting/referenceexpression.md))
  The expression to evaluate when TLS is enabled (e.g., `",ssl=true"`).
- `disabledValue` ([ReferenceExpression](/reference/api/csharp/aspire.hosting/referenceexpression.md))
  The expression to evaluate when TLS is not enabled.

## Returns

[ReferenceExpression](/reference/api/csharp/aspire.hosting/referenceexpression.md) -- A conditional [ReferenceExpression](/reference/api/csharp/aspire.hosting/referenceexpression.md) whose value tracks the TLS state of this endpoint.

## Remarks

The returned expression evaluates the TLS state lazily each time its value is resolved, making it safe to embed in a [ReferenceExpression](/reference/api/csharp/aspire.hosting/referenceexpression.md) that is built before TLS is configured (e.g., before `BeforeStartEvent` fires). Because the condition and branches are declarative, polyglot code generators can translate this into native conditional constructs in any target language.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## GetValueAsync(CancellationToken)

- Name: `GetValueAsync(CancellationToken)`
- Returns: `ValueTask<string?>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L98)

Gets the URL of the endpoint asynchronously. Waits for the endpoint to be allocated if necessary.

```csharp
public sealed class EndpointReference
{
    public ValueTask<string?> GetValueAsync(
        CancellationToken cancellationToken = default(CancellationToken))
    {
        // ...
    }
}
```

## Parameters

- `cancellationToken` (`CancellationToken`) `optional`
  The cancellation token.

## Returns

`ValueTask<string?>` -- The URL of the endpoint.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## GetValueAsync(ValueProviderContext, CancellationToken)

- Name: `GetValueAsync(ValueProviderContext, CancellationToken)`
- Returns: `ValueTask<string?>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L107)

Gets the URL of the endpoint asynchronously. Waits for the endpoint to be allocated if necessary.

```csharp
public sealed class EndpointReference
{
    public ValueTask<string?> GetValueAsync(
        ValueProviderContext context,
        CancellationToken cancellationToken = default(CancellationToken))
    {
        // ...
    }
}
```

## Parameters

- `context` ([ValueProviderContext](/reference/api/csharp/aspire.hosting/valueprovidercontext.md))
  The context for value resolution.
- `cancellationToken` (`CancellationToken`) `optional`
  The cancellation token.

## Returns

`ValueTask<string?>` -- The URL of the endpoint.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## Property(EndpointProperty)

- Name: `Property(EndpointProperty)`
- Returns: [EndpointReferenceExpression](/reference/api/csharp/aspire.hosting/endpointreferenceexpression.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L144)

Gets the specified property expression of the endpoint.

```csharp
public sealed class EndpointReference
{
    public EndpointReferenceExpression Property(
        EndpointProperty property)
    {
        // ...
    }
}
```

## Parameters

- `property` ([EndpointProperty](/reference/api/csharp/aspire.hosting/endpointproperty.md))
  The [EndpointProperty](/reference/api/csharp/aspire.hosting/endpointproperty.md) enum value to use in the reference.

## Returns

[EndpointReferenceExpression](/reference/api/csharp/aspire.hosting/endpointreferenceexpression.md) -- An [EndpointReferenceExpression](/reference/api/csharp/aspire.hosting/endpointreferenceexpression.md) representing the specified [EndpointProperty](/reference/api/csharp/aspire.hosting/endpointproperty.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
