---
title: "Class RenderingEngineMiddleware"
slug: "sitecore.aspnet.renderingengine.middleware.renderingenginemiddleware"
abstract: ""
---
# Class RenderingEngineMiddleware

The Rendering Engine middleware implementation that calls the Sitecore layout service and stores the [ISitecoreRenderingContext](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.aspnet.renderingengine.isitecorerenderingcontext.html) as a Microsoft.AspNetCore.Http.HttpContext feature.

## Inheritance

System.Object

RenderingEngineMiddleware

### **Namespace**: Sitecore.AspNet.RenderingEngine.Middleware

#### **Assembly**: Sitecore.AspNet.RenderingEngine.dll

##### Syntax

```csharp
public class RenderingEngineMiddleware : Object

```

### Constructors

#### RenderingEngineMiddleware(RequestDelegate, ISitecoreLayoutRequestMapper, ISitecoreLayoutClient, IOptions<RenderingEngineOptions>)

Initializes a new instance of the [RenderingEngineMiddleware](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.aspnet.renderingengine.middleware.renderingenginemiddleware.html) class.

##### Declaration

```csharp
public RenderingEngineMiddleware(RequestDelegate next, ISitecoreLayoutRequestMapper requestMapper, ISitecoreLayoutClient layoutService, IOptions<RenderingEngineOptions> options)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Microsoft.AspNetCore.Http.RequestDelegate | next | The next middleware to call. |
| ISitecoreLayoutRequestMapper | requestMapper | The [ISitecoreLayoutRequestMapper](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.aspnet.renderingengine.isitecorelayoutrequestmapper.html) to map the HttpRequest to a Layout Service request. |
| ISitecoreLayoutClient | layoutService | The layout service client. |
| Microsoft.Extensions.Options.IOptions<br><br><<br><br>RenderingEngineOptions<br><br>> | options | Rendering Engine options. |

### Methods

#### Invoke(HttpContext, IViewComponentHelper, IHtmlHelper)

The middleware Invoke method.

##### Declaration

```csharp
public Task Invoke(HttpContext httpContext, IViewComponentHelper viewComponentHelper, IHtmlHelper htmlHelper)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Microsoft.AspNetCore.Http.HttpContext | httpContext | The current Microsoft.AspNetCore.Http.HttpContext. |
| Microsoft.AspNetCore.Mvc.IViewComponentHelper | viewComponentHelper | The current Microsoft.AspNetCore.Mvc.IViewComponentHelper. |
| Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper | htmlHelper | The current Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper. |

##### Returns

| Type | Description |
| --- | --- |
| System.Threading.Tasks.Task | A System.Threading.Tasks.Task to support async calls. |
