# EndpointReference Properties

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

Represents an endpoint reference for a resource with endpoints.

## ContextNetworkID

- Name: `ContextNetworkID`
- Modifiers: `nullable` `get`
- Returns: [NetworkIdentifier?](/reference/api/csharp/aspire.hosting/networkidentifier.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L114)

The ID of the network that serves as the context for the EndpointReference. The reference will be resolved in the context of this network, which may be different from the network associated with the default network of the referenced Endpoint.

```csharp
public NetworkIdentifier? ContextNetworkID { get; }
```

## EndpointAnnotation

- Name: `EndpointAnnotation`
- Modifiers: `get`
- Returns: [EndpointAnnotation](/reference/api/csharp/aspire.hosting/endpointannotation.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L24)

Gets the endpoint annotation associated with the endpoint reference.

```csharp
public EndpointAnnotation EndpointAnnotation { get; }
```

## EndpointName

- Name: `EndpointName`
- Modifiers: `get`
- Returns: `string`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L36)

Gets the name of the endpoint associated with the endpoint reference.

```csharp
public string EndpointName { get; }
```

## ErrorMessage

- Name: `ErrorMessage`
- Modifiers: `nullable` `get; init`
- Returns: `string?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs)

Gets or sets a custom error message to be thrown when the endpoint annotation is not found.

```csharp
public string? ErrorMessage { get; init; }
```

## ExcludeReferenceEndpoint

- Name: `ExcludeReferenceEndpoint`
- Modifiers: `get`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L88)

Gets a value indicating whether this endpoint is excluded from the default set when referencing the resource's endpoints.

```csharp
public bool ExcludeReferenceEndpoint { get; }
```

## Remarks

Returns `false` if the endpoint annotation has not been added to the resource yet. Once the annotation exists, this property delegates to [EndpointAnnotation.ExcludeReferenceEndpoint](/reference/api/csharp/aspire.hosting/endpointannotation/properties.md#excludereferenceendpoint).

## Exists

- Name: `Exists`
- Modifiers: `get`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L51)

Gets a value indicating whether the endpoint exists.

```csharp
public bool Exists { get; }
```

## Host

- Name: `Host`
- Modifiers: `get`
- Returns: `string`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L184)

Gets the host for this endpoint.

```csharp
public string Host { get; }
```

## IsAllocated

- Name: `IsAllocated`
- Modifiers: `get`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L46)

Gets a value indicating whether the endpoint is allocated.

```csharp
public bool IsAllocated { get; }
```

## IsHttp

- Name: `IsHttp`
- Modifiers: `get`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L56)

Gets a value indicating whether the endpoint uses HTTP scheme.

```csharp
public bool IsHttp { get; }
```

## IsHttps

- Name: `IsHttps`
- Modifiers: `get`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L61)

Gets a value indicating whether the endpoint uses HTTPS scheme.

```csharp
public bool IsHttps { get; }
```

## IsHttpSchemeNamedEndpoint

- Name: `IsHttpSchemeNamedEndpoint`
- Modifiers: `get`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L78-L79)

Gets a value indicating whether the endpoint name is "http" or "https", ignoring case. This is a convention used to identify endpoints that will be resolved based on the scheme of the endpoint in service discovery rather than by the specific endpoint name. This is done to allow http endpoints that are dynamically updated to https to be mapped correctly despite the endpoint name no longer matching the scheme.

```csharp
public bool IsHttpSchemeNamedEndpoint { get; }
```

## Port

- Name: `Port`
- Modifiers: `get`
- Returns: `int`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L174)

Gets the port for this endpoint.

```csharp
public int Port { get; }
```

## Resource

- Name: `Resource`
- Modifiers: `get`
- Returns: [IResourceWithEndpoints](/reference/api/csharp/aspire.hosting/iresourcewithendpoints.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L29)

Gets the resource owner of the endpoint reference.

```csharp
public IResourceWithEndpoints Resource { get; }
```

## Scheme

- Name: `Scheme`
- Modifiers: `get`
- Returns: `string`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L189)

Gets the scheme for this endpoint.

```csharp
public string Scheme { get; }
```

## TargetPort

- Name: `TargetPort`
- Modifiers: `nullable` `get`
- Returns: `int?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L179)

Gets the target port for this endpoint. If the port is dynamically allocated, this will return `null`.

```csharp
public int? TargetPort { get; }
```

## TlsEnabled

- Name: `TlsEnabled`
- Modifiers: `get`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L70)

Gets a value indicating whether TLS is enabled for this endpoint.

```csharp
public bool TlsEnabled { get; }
```

## Remarks

Returns `false` if the endpoint annotation has not been added to the resource yet. Once the annotation exists, this property delegates to [EndpointAnnotation.TlsEnabled](/reference/api/csharp/aspire.hosting/endpointannotation/properties.md#tlsenabled).

## Url

- Name: `Url`
- Modifiers: `get`
- Returns: `string`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs#L194)

Gets the URL for this endpoint.

```csharp
public string Url { get; }
```
