---
title: "Class SitecoreLayoutClientBuilderExtensions"
slug: "sitecore.layoutservice.client.extensions.sitecorelayoutclientbuilderextensions"
abstract: ""
---
# Class SitecoreLayoutClientBuilderExtensions

Extension methods to support configuration of layout service services.

## Inheritance

System.Object

SitecoreLayoutClientBuilderExtensions

### **Namespace**: Sitecore.LayoutService.Client.Extensions

#### **Assembly**: Sitecore.LayoutService.Client.dll

##### Syntax

```csharp
public static class SitecoreLayoutClientBuilderExtensions : Object

```

### Methods

#### AddGraphQlHandler(ISitecoreLayoutClientBuilder, String, String, String, Uri)

Registers a graphQl handler to handle requests.

##### Declaration

```csharp
public static ILayoutRequestHandlerBuilder<GraphQlLayoutServiceHandler> AddGraphQlHandler(this ISitecoreLayoutClientBuilder builder, string name, string siteName, string apiKey, Uri uri)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| ISitecoreLayoutClientBuilder | builder | The [ISitecoreLayoutClientBuilder](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.isitecorelayoutclientbuilder.html) being configured. |
| System.String | name | The name used to identify the handler. |
| System.String | siteName | The siteName used to identify the handler. |
| System.String | apiKey | The apiKey to access graphQl endpoint. |
| System.Uri | uri | GraphQl endpoint uri. |

##### Returns

| Type | Description |
| --- | --- |
| ILayoutRequestHandlerBuilder<br><br><<br><br>GraphQlLayoutServiceHandler<br><br>> | The [ILayoutRequestHandlerBuilder<THandler>](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.ilayoutrequesthandlerbuilder-1.html) so that additional calls can be chained. |

#### AddHandler<THandler>(ISitecoreLayoutClientBuilder, String, Func<IServiceProvider, THandler>)

Registers a handler of type `THandler` to handle requests.

##### Declaration

```csharp
public static ILayoutRequestHandlerBuilder<THandler> AddHandler<THandler>(this ISitecoreLayoutClientBuilder builder, string name, Func<IServiceProvider, THandler> factory = null)
    where THandler : ILayoutRequestHandler

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| ISitecoreLayoutClientBuilder | builder | The [ISitecoreLayoutClientBuilder](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.isitecorelayoutclientbuilder.html) being configured. |
| System.String | name | The name used to identify the handler. |
| System.Func<br><br><<br><br>System.IServiceProvider<br><br>, THandler> | factory | Optional factory to control the instantiation of the client. |

##### Returns

| Type | Description |
| --- | --- |
| ILayoutRequestHandlerBuilder<br><br><THandler> | The [ILayoutRequestHandlerBuilder<THandler>](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.ilayoutrequesthandlerbuilder-1.html) so that additional calls can be chained. |

##### Type Parameters

| Name | Description |
| --- | --- |
| THandler | The type of service to be registered for this `name`. |

#### AddSystemTextJson(ISitecoreLayoutClientBuilder)

Configures System.Text.Json specific features such as input and output formatters.

##### Declaration

```csharp
public static ISitecoreLayoutClientBuilder AddSystemTextJson(this ISitecoreLayoutClientBuilder builder)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| ISitecoreLayoutClientBuilder | builder | The [ISitecoreLayoutClientBuilder](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.isitecorelayoutclientbuilder.html) being configured. |

##### Returns

| Type | Description |
| --- | --- |
| ISitecoreLayoutClientBuilder | The [ILayoutRequestHandlerBuilder<THandler>](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.ilayoutrequesthandlerbuilder-1.html) so that additional calls can be chained. |

#### WithDefaultRequestOptions(ISitecoreLayoutClientBuilder, Action<SitecoreLayoutRequest>)

Registers the default layout service request options for all handlers.

##### Declaration

```csharp
public static ISitecoreLayoutClientBuilder WithDefaultRequestOptions(this ISitecoreLayoutClientBuilder builder, Action<SitecoreLayoutRequest> configureRequest)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| ISitecoreLayoutClientBuilder | builder | The [ISitecoreLayoutClientBuilder](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.isitecorelayoutclientbuilder.html) being configured. |
| System.Action<br><br><<br><br>SitecoreLayoutRequest<br><br>> | configureRequest | The [SitecoreLayoutRequest](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.request.sitecorelayoutrequest.html) request options configuration. |

##### Returns

| Type | Description |
| --- | --- |
| ISitecoreLayoutClientBuilder | The configured [ISitecoreLayoutClientBuilder](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.isitecorelayoutclientbuilder.html). |
