---
title: "Class HttpContextExtensions"
slug: "sitecore.aspnet.renderingengine.httpcontextextensions"
abstract: ""
---
# Class HttpContextExtensions

Extension methods to support the Microsoft.AspNetCore.Http.HttpContext.

## Inheritance

System.Object

HttpContextExtensions

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

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

##### Syntax

```csharp
public static class HttpContextExtensions : Object

```

### Methods

#### GetSitecoreRenderingContext(HttpContext)

Gets the [ISitecoreRenderingContext](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.aspnet.renderingengine.isitecorerenderingcontext.html) from the Microsoft.AspNetCore.Http.HttpContext.

##### Declaration

```csharp
public static ISitecoreRenderingContext GetSitecoreRenderingContext(this HttpContext context)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Microsoft.AspNetCore.Http.HttpContext | context | The Microsoft.AspNetCore.Http.HttpContext instance to retrieve the Sitecore rendering context from. |

##### Returns

| Type | Description |
| --- | --- |
| ISitecoreRenderingContext | The [ISitecoreRenderingContext](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.aspnet.renderingengine.isitecorerenderingcontext.html) instance. |

#### SetSitecoreRenderingContext(HttpContext, ISitecoreRenderingContext)

Sets the [ISitecoreRenderingContext](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.aspnet.renderingengine.isitecorerenderingcontext.html) in the current Microsoft.AspNetCore.Http.HttpContext.Features collection.

##### Declaration

```csharp
public static void SetSitecoreRenderingContext(this HttpContext context, ISitecoreRenderingContext renderingContext)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Microsoft.AspNetCore.Http.HttpContext | context | The current Microsoft.AspNetCore.Http.HttpContext. |
| ISitecoreRenderingContext | renderingContext | The [ISitecoreRenderingContext](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.aspnet.renderingengine.isitecorerenderingcontext.html) to save in the feature collection. |
