# EndpointReferenceExpression Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [EndpointReferenceExpression](/reference/api/csharp/aspire.hosting/endpointreferenceexpression.md)
- Kind: `Methods`
- Members: `2`

Represents a property expression for an endpoint reference.

## GetValueAsync(CancellationToken)

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

Gets the value of the property of the endpoint.

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

## Parameters

- `cancellationToken` (`CancellationToken`) `optional`
  A `Threading.CancellationToken`.

## Returns

`ValueTask<string?>` -- A `String` containing the selected [EndpointProperty](/reference/api/csharp/aspire.hosting/endpointproperty.md) value.

## Exceptions

- `InvalidOperationException` -- Throws when the selected [EndpointProperty](/reference/api/csharp/aspire.hosting/endpointproperty.md) enumeration is not known.

## 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#L338)

Gets the value of the property of the endpoint.

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

## Parameters

- `context` ([ValueProviderContext](/reference/api/csharp/aspire.hosting/valueprovidercontext.md))
  The context to use when resolving the endpoint property.
- `cancellationToken` (`CancellationToken`) `optional`
  A `Threading.CancellationToken`.

## Returns

`ValueTask<string?>` -- A `String` containing the selected [EndpointProperty](/reference/api/csharp/aspire.hosting/endpointproperty.md) value.

## Exceptions

- `InvalidOperationException` -- Throws when the selected [EndpointProperty](/reference/api/csharp/aspire.hosting/endpointproperty.md) enumeration is not known.
