# InteractionResult Methods

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

Provides a set of static methods for the `Hosting.InteractionResult`1`.

## Cancel(T?)

- Name: `Cancel(T?)`
- Modifiers: `static`
- Returns: [InteractionResult<T>](/reference/api/csharp/aspire.hosting/interactionresult-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/a3766e994fd2cba86c8ac60b8a80268cab7e6383/src/Aspire.Hosting/IInteractionService.cs#L783)

Creates an `Hosting.InteractionResult`1` indicating a canceled interaction.

```csharp
public static class InteractionResult
{
    public static InteractionResult<T> Cancel<T>(
        T? data = default(T?))
    {
        // ...
    }
}
```

## Parameters

- `data` (`T?`) `optional`
  Optional data to include with the interaction result. Defaults to the default value of type `T` if not provided.

## Returns

[InteractionResult<T>](/reference/api/csharp/aspire.hosting/interactionresult-1.md) -- An `Hosting.InteractionResult`1` with the `canceled` flag set to `true` and containing the specified data.

## Ok(T)

- Name: `Ok(T)`
- Modifiers: `static`
- Returns: [InteractionResult<T>](/reference/api/csharp/aspire.hosting/interactionresult-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/a3766e994fd2cba86c8ac60b8a80268cab7e6383/src/Aspire.Hosting/IInteractionService.cs#L768)

Creates a new `Hosting.InteractionResult`1` with the specified result and a flag indicating that the interaction was not canceled.

```csharp
public static class InteractionResult
{
    public static InteractionResult<T> Ok<T>(
        T result)
    {
        // ...
    }
}
```

## Parameters

- `result` (`T`)
  The data returned from the interaction.

## Returns

[InteractionResult<T>](/reference/api/csharp/aspire.hosting/interactionresult-1.md) -- The new `Hosting.InteractionResult`1`.
