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
stringKey name.
value
stringValue 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
stringHeader 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
stringHeader name to copy.
destination
IDictionary<string, string[]>Destination collection.
GetSitecoreRenderingContext(HttpContext)
Gets the ISitecoreRenderingContext from the HttpContext.
public static ISitecoreRenderingContext? GetSitecoreRenderingContext(this HttpContext context)
Parameters
context
HttpContextThe 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
HttpContextHttp context.
siteName
stringSitecore rendering context.
SetSitecoreRenderingContext(HttpContext, ISitecoreRenderingContext)
Sets the ISitecoreRenderingContext in the current Features collection.
public static void SetSitecoreRenderingContext(this HttpContext context, ISitecoreRenderingContext renderingContext)
Parameters
context
HttpContextThe current HttpContext.
renderingContext
ISitecoreRenderingContextThe 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
HttpContextHttp context.
resolvedSiteName
stringResolved 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
ISitecoreRenderingContextSitecore rendering context.
context
HttpContextHttp context.