Table of Contents

Class HttpContextExtensions

Namespace
Sitecore.AspNetCore.SDK.RenderingEngine.Extensions
Assembly
Sitecore.AspNetCore.SDK.RenderingEngine.dll

Http context extensions.

public static class HttpContextExtensions
Inheritance
HttpContextExtensions
Inherited Members

Methods

AppendValue(IDictionary<string, string[]>, string, string)

Extension method for collection manipulation simplifications. It inserts/appends string value to dictionary item. Is useful for headers manipulations.

public static void AppendValue(this IDictionary<string, string[]> collection, string key, string value)

Parameters

collection IDictionary<string, string[]>

Destination collection.

key string

Key name.

value string

Value to be added to values array.

CopyHeader(IEnumerable<KeyValuePair<string, StringValues>>, string, IDictionary<string, string[]>)

Extension method for copying of Http headers.

public static void CopyHeader(this IEnumerable<KeyValuePair<string, StringValues>> source, string headerKey, IDictionary<string, string[]> destination)

Parameters

source IEnumerable<KeyValuePair<string, StringValues>>

Source collection.

headerKey string

Header name to copy.

destination IDictionary<string, string[]>

Destination collection.

CopyHeader(ILookup<string, string>, string, IDictionary<string, string[]>)

Extension method for copying of Http headers.

public static void CopyHeader(this ILookup<string, string> source, string headerKey, IDictionary<string, string[]> destination)

Parameters

source ILookup<string, string>

Source collection.

headerKey string

Header name to copy.

destination IDictionary<string, string[]>

Destination collection.

GetSitecoreRenderingContext(HttpContext)

public static ISitecoreRenderingContext? GetSitecoreRenderingContext(this HttpContext context)

Parameters

context HttpContext

The HttpContext instance to retrieve the Sitecore rendering context from.

Returns

ISitecoreRenderingContext

The ISitecoreRenderingContext instance.

SetResolvedSiteName(HttpContext, string)

Sets request resolved site name globally for using it between middlewares.

public static void SetResolvedSiteName(this HttpContext context, string siteName)

Parameters

context HttpContext

Http context.

siteName string

Sitecore rendering context.

SetSitecoreRenderingContext(HttpContext, ISitecoreRenderingContext)

Sets the ISitecoreRenderingContext in the current Features collection.

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

Parameters

context HttpContext

The current HttpContext.

renderingContext ISitecoreRenderingContext

The ISitecoreRenderingContext to save in the feature collection.

TryGetResolvedSiteName(HttpContext, out string?)

Try get request resolved site name.

public static bool TryGetResolvedSiteName(this HttpContext context, out string? resolvedSiteName)

Parameters

context HttpContext

Http context.

resolvedSiteName string

Resolved site name out param.

Returns

bool

Result boolean value.

UpdateResponseWithLayoutMetadata(ISitecoreRenderingContext, HttpContext)

Updates response with metadata from sitecore rendering context.

public static void UpdateResponseWithLayoutMetadata(this ISitecoreRenderingContext renderingContext, HttpContext context)

Parameters

renderingContext ISitecoreRenderingContext

Sitecore rendering context.

context HttpContext

Http context.