# ResponseTransformExtensions Methods

- Package: [Aspire.Hosting.Yarp](/reference/api/csharp/aspire.hosting.yarp.md)
- Type: [ResponseTransformExtensions](/reference/api/csharp/aspire.hosting.yarp/responsetransformextensions.md)
- Kind: `Methods`
- Members: `8`

Extensions for adding response header and trailer transforms.

## WithTransformCopyResponseHeaders(YarpRoute, bool)

- Name: `WithTransformCopyResponseHeaders(YarpRoute, bool)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/ResponseTransformExtensions.cs#L19-L20)

Adds the transform which will enable or suppress copying response headers to the client response.

```csharp
public static class ResponseTransformExtensions
{
    public static YarpRoute WithTransformCopyResponseHeaders(
        this YarpRoute route,
        bool copy = true)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `copy` (`bool`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformCopyResponseTrailers(YarpRoute, bool)

- Name: `WithTransformCopyResponseTrailers(YarpRoute, bool)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/ResponseTransformExtensions.cs#L29-L30)

Adds the transform which will enable or suppress copying response trailers to the client response.

```csharp
public static class ResponseTransformExtensions
{
    public static YarpRoute WithTransformCopyResponseTrailers(
        this YarpRoute route,
        bool copy = true)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `copy` (`bool`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformResponseHeader(YarpRoute, string, string, bool, ResponseCondition)

- Name: `WithTransformResponseHeader(YarpRoute, string, string, bool, ResponseCondition)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/ResponseTransformExtensions.cs#L39-L40)

Adds the transform which will append or set the response header.

```csharp
public static class ResponseTransformExtensions
{
    public static YarpRoute WithTransformResponseHeader(
        this YarpRoute route,
        string headerName,
        string value,
        bool append = true,
        ResponseCondition condition = ResponseCondition.Success)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `headerName` (`string`)
- `value` (`string`)
- `append` (`bool`) `optional`
- `condition` (`ResponseCondition`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformResponseHeaderRemove(YarpRoute, string, ResponseCondition)

- Name: `WithTransformResponseHeaderRemove(YarpRoute, string, ResponseCondition)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/ResponseTransformExtensions.cs#L49-L50)

Adds the transform which will remove the response header.

```csharp
public static class ResponseTransformExtensions
{
    public static YarpRoute WithTransformResponseHeaderRemove(
        this YarpRoute route,
        string headerName,
        ResponseCondition condition = ResponseCondition.Success)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `headerName` (`string`)
- `condition` (`ResponseCondition`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformResponseHeadersAllowed(YarpRoute, string[])

- Name: `WithTransformResponseHeadersAllowed(YarpRoute, string[])`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/ResponseTransformExtensions.cs#L60-L61)

Adds the transform which will only copy the allowed response headers. Other transforms that modify or append to existing headers may be affected if not included in the allow list.

```csharp
public static class ResponseTransformExtensions
{
    public static YarpRoute WithTransformResponseHeadersAllowed(
        this YarpRoute route,
        params string[] allowedHeaders)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `allowedHeaders` (`string[]`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformResponseTrailer(YarpRoute, string, string, bool, ResponseCondition)

- Name: `WithTransformResponseTrailer(YarpRoute, string, string, bool, ResponseCondition)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/ResponseTransformExtensions.cs#L70-L71)

Adds the transform which will append or set the response trailer.

```csharp
public static class ResponseTransformExtensions
{
    public static YarpRoute WithTransformResponseTrailer(
        this YarpRoute route,
        string headerName,
        string value,
        bool append = true,
        ResponseCondition condition = ResponseCondition.Success)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `headerName` (`string`)
- `value` (`string`)
- `append` (`bool`) `optional`
- `condition` (`ResponseCondition`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformResponseTrailerRemove(YarpRoute, string, ResponseCondition)

- Name: `WithTransformResponseTrailerRemove(YarpRoute, string, ResponseCondition)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/ResponseTransformExtensions.cs#L80-L81)

Adds the transform which will remove the response trailer.

```csharp
public static class ResponseTransformExtensions
{
    public static YarpRoute WithTransformResponseTrailerRemove(
        this YarpRoute route,
        string headerName,
        ResponseCondition condition = ResponseCondition.Success)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `headerName` (`string`)
- `condition` (`ResponseCondition`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformResponseTrailersAllowed(YarpRoute, string[])

- Name: `WithTransformResponseTrailersAllowed(YarpRoute, string[])`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/ResponseTransformExtensions.cs#L91-L92)

Adds the transform which will only copy the allowed response trailers. Other transforms that modify or append to existing trailers may be affected if not included in the allow list.

```csharp
public static class ResponseTransformExtensions
{
    public static YarpRoute WithTransformResponseTrailersAllowed(
        this YarpRoute route,
        params string[] allowedHeaders)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `allowedHeaders` (`string[]`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
