# ForwardedTransformExtensions Methods

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

Extensions for adding forwarded header transforms.

## WithTransformClientCertHeader(YarpRoute, string)

- Name: `WithTransformClientCertHeader(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/ForwardedTransformExtensions.cs#L48-L49)

Adds the transform which will set the given header with the Base64 encoded client certificate.

```csharp
public static class ForwardedTransformExtensions
{
    public static YarpRoute WithTransformClientCertHeader(
        this YarpRoute route,
        string headerName)
    {
        // ...
    }
}
```

## Parameters

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

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformForwarded(YarpRoute, bool, bool, NodeFormat, NodeFormat, ForwardedTransformActions)

- Name: `WithTransformForwarded(YarpRoute, bool, bool, NodeFormat, NodeFormat, ForwardedTransformActions)`
- 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/ForwardedTransformExtensions.cs#L38-L39)

Adds the transform which will add the Forwarded header as defined by [RFC 7239](https://tools.ietf.org/html/rfc7239).

```csharp
public static class ForwardedTransformExtensions
{
    public static YarpRoute WithTransformForwarded(
        this YarpRoute route,
        bool useHost = true,
        bool useProto = true,
        NodeFormat forFormat = NodeFormat.Random,
        NodeFormat byFormat = NodeFormat.Random,
        ForwardedTransformActions action = ForwardedTransformActions.Set)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `useHost` (`bool`) `optional`
- `useProto` (`bool`) `optional`
- `forFormat` (`NodeFormat`) `optional`
- `byFormat` (`NodeFormat`) `optional`
- `action` (`ForwardedTransformActions`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransformXForwarded(YarpRoute, string, ForwardedTransformActions, ForwardedTransformActions?, ForwardedTransformActions?, ForwardedTransformActions?, ForwardedTransformActions?)

- Name: `WithTransformXForwarded(YarpRoute, string, ForwardedTransformActions, ForwardedTransformActions?, ForwardedTransformActions?, ForwardedTransformActions?, ForwardedTransformActions?)`
- 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/ForwardedTransformExtensions.cs#L27-L28)

Adds the transform which will add X-Forwarded-* headers.

```csharp
public static class ForwardedTransformExtensions
{
    public static YarpRoute WithTransformXForwarded(
        this YarpRoute route,
        string headerPrefix = "X-Forwarded-",
        ForwardedTransformActions xDefault = ForwardedTransformActions.Set,
        ForwardedTransformActions? xFor = null,
        ForwardedTransformActions? xHost = null,
        ForwardedTransformActions? xProto = null,
        ForwardedTransformActions? xPrefix = null)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `headerPrefix` (`string`) `optional`
- `xDefault` (`ForwardedTransformActions`) `optional`
- `xFor` (`ForwardedTransformActions?`) `optional`
- `xHost` (`ForwardedTransformActions?`) `optional`
- `xProto` (`ForwardedTransformActions?`) `optional`
- `xPrefix` (`ForwardedTransformActions?`) `optional`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
