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
collectionIDictionary<string, string[]>Destination collection.
keystringKey name.
valuestringValue 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
sourceIEnumerable<KeyValuePair<string, StringValues>>Source collection.
headerKeystringHeader name to copy.
destinationIDictionary<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
sourceILookup<string, string>Source collection.
headerKeystringHeader name to copy.
destinationIDictionary<string, string[]>Destination collection.
GetSitecoreRenderingContext(HttpContext)
Gets the ISitecoreRenderingContext from the HttpContext.
public static ISitecoreRenderingContext? GetSitecoreRenderingContext(this HttpContext context)
Parameters
contextHttpContextThe 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
contextHttpContextHttp context.
siteNamestringSitecore rendering context.
SetSitecoreRenderingContext(HttpContext, ISitecoreRenderingContext)
Sets the ISitecoreRenderingContext in the current Features collection.
public static void SetSitecoreRenderingContext(this HttpContext context, ISitecoreRenderingContext renderingContext)
Parameters
contextHttpContextThe current HttpContext.
renderingContextISitecoreRenderingContextThe 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
contextHttpContextHttp context.
resolvedSiteNamestringResolved 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
renderingContextISitecoreRenderingContextSitecore rendering context.
contextHttpContextHttp context.