Class HttpContextExtensions

Version: 21.x

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

Inheritance

System.Object

HttpContextExtensions

Namespace: Sitecore.AspNet.RenderingEngine

Assembly: Sitecore.AspNet.RenderingEngine.dll

Syntax
public static class HttpContextExtensions : Object

Methods

GetSitecoreRenderingContext(HttpContext)

Gets the ISitecoreRenderingContext from the Microsoft.AspNetCore.Http.HttpContext.

Declaration
public static ISitecoreRenderingContext GetSitecoreRenderingContext(this HttpContext context)
Parameters
TypeNameDescription
Microsoft.AspNetCore.Http.HttpContextcontextThe Microsoft.AspNetCore.Http.HttpContext instance to retrieve the Sitecore rendering context from.
Returns
TypeDescription
ISitecoreRenderingContextThe ISitecoreRenderingContext instance.

SetSitecoreRenderingContext(HttpContext, ISitecoreRenderingContext)

Sets the ISitecoreRenderingContext in the current Microsoft.AspNetCore.Http.HttpContext.Features collection.

Declaration
public static void SetSitecoreRenderingContext(this HttpContext context, ISitecoreRenderingContext renderingContext)
Parameters
TypeNameDescription
Microsoft.AspNetCore.Http.HttpContextcontextThe current Microsoft.AspNetCore.Http.HttpContext.
ISitecoreRenderingContextrenderingContextThe ISitecoreRenderingContext to save in the feature collection.
If you have suggestions for improving this article, let us know!