# AspireTerminal

- Kind: `class`
- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Version: `13.6.0`
- Namespace: `Aspire.Hosting.ApplicationModel`
- Target framework: `net10.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting/ApplicationModel/AspireTerminal.cs)
- Implements: `IAsyncDisposable`

An Aspire-owned terminal handle for dashboard interaction and automation from AppHost code.

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel;

public sealed class AspireTerminal
    : System.IAsyncDisposable
{
    // ...
}
```

## Remarks

Obtain a handle from [TerminalService.CreateTerminal(TerminalLaunchOptions)](/reference/api/csharp/aspire.hosting/terminalservice/methods.md#createterminal-terminallaunchoptions) or [TerminalService.TryGetTerminal(string, AspireTerminal?)](/reference/api/csharp/aspire.hosting/terminalservice/methods.md#trygetterminal-string-aspireterminal). Handles cannot be constructed or extended by callers; Aspire manages their registration and connection to the underlying terminal implementation.

What disposal means depends on [AspireTerminal.Owner](/reference/api/csharp/aspire.hosting/aspireterminal/properties.md#owner). For [TerminalOwner.AppHost](/reference/api/csharp/aspire.hosting/terminalowner/fields.md) the AppHost owns the workload, so disposing stops it and removes the terminal from the dashboard; whoever creates such a terminal owns it and must dispose it, and showing one in an interaction does not transfer that ownership, so the terminal survives the dialog it was displayed in. For [TerminalOwner.Resource](/reference/api/csharp/aspire.hosting/terminalowner/fields.md) the workload belongs to the resource, so disposing only releases Aspire's handle and leaves the workload running.

When an AppHost-owned workload ends, its terminal remains in the dashboard until disposed, but no longer accepts input or automation. Reopening an ended terminal displays its ended state rather than replaying output.

## Properties

- [Id](/reference/api/csharp/aspire.hosting/aspireterminal/properties.md#id) : `string` `get` -- Gets the opaque identifier used to address this terminal over the dashboard connection.
- [Owner](/reference/api/csharp/aspire.hosting/aspireterminal/properties.md#owner) : [TerminalOwner](/reference/api/csharp/aspire.hosting/terminalowner.md) `get` -- Gets the process that owns this terminal's workload.
- [Placement](/reference/api/csharp/aspire.hosting/aspireterminal/properties.md#placement) : [TerminalPlacement](/reference/api/csharp/aspire.hosting/terminalplacement.md) `get` -- Gets where this terminal is displayed in the dashboard.
- [Title](/reference/api/csharp/aspire.hosting/aspireterminal/properties.md#title) : `string` `get` -- Gets the title shown on the terminal's dock tab.

## Methods

- [DisposeAsync](/reference/api/csharp/aspire.hosting/aspireterminal/methods.md#disposeasync) : `ValueTask` -- Releases the handle, stopping the workload only when it is owned by the AppHost.
- [GetScreenText](/reference/api/csharp/aspire.hosting/aspireterminal/methods.md#getscreentext) : `string` -- Gets the current contents of the terminal screen, with lines separated by newlines.
- [SendKeyAsync(AspireTerminalKey, CancellationToken)](/reference/api/csharp/aspire.hosting/aspireterminal/methods.md#sendkeyasync-aspireterminalkey-cancellationtoken) : `Task` -- Sends a single key, optionally combined with modifiers, to the terminal's workload.
- [SendTextAsync(string, CancellationToken)](/reference/api/csharp/aspire.hosting/aspireterminal/methods.md#sendtextasync-string-cancellationtoken) : `Task` -- Sends text to the terminal's workload as though it had been typed.
- [Show](/reference/api/csharp/aspire.hosting/aspireterminal/methods.md#show) -- Reveals the terminal dock in every connected dashboard and switches to this terminal's tab.
- [Start](/reference/api/csharp/aspire.hosting/aspireterminal/methods.md#start) -- Starts the terminal's workload if it is not already running.
- [WaitForTextAsync(string, TimeSpan?, CancellationToken)](/reference/api/csharp/aspire.hosting/aspireterminal/methods.md#waitfortextasync-string-timespan-cancellationtoken) : `Task` -- Waits until `text` appears on the terminal screen.
