# AspireDtoAttribute

- Kind: `class`
- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Version: `13.3.0`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/Ats/AspireDtoAttribute.cs)
- Inherits: `Attribute`

Marks a class as an ATS (Aspire Type System) Data Transfer Object. DTOs are serializable types used to pass structured data to capabilities.

## Definition

```csharp
namespace Aspire.Hosting;

public sealed class AspireDtoAttribute
    : System.Attribute
{
    // ...
}
```

## Remarks

DTOs should be simple record or class types with properties that can be serialized to/from JSON. They should not contain complex .NET types like IConfiguration, ILogger, or other framework-specific types.

Example:

```csharp
[AspireDto]
public sealed class AddRedisOptions {
    public required string Name { get; init; }
    public int? Port { get; init; }
}
```

## Constructors

- [AspireDtoAttribute](/reference/api/csharp/aspire.hosting/aspiredtoattribute/constructors.md#constructor)

## Properties

- [DtoTypeId](/reference/api/csharp/aspire.hosting/aspiredtoattribute/properties.md#dtotypeid) : `string?` `get; set` -- Gets or sets an optional type identifier for this DTO. If not specified, the DTO will be serialized as a plain JSON object.
