KestrunContext record

Represents the context for a Kestrun request, including the request, response, HTTP context, and host.

public record KestrunContext

Public Members

name description
KestrunContext(…) Initializes a new instance of the KestrunContext class. This constructor is used when creating a new KestrunContext from an existing HTTP context. It initializes the KestrunRequest and KestrunResponse based on the provided HttpContext
Connection { get; } Gets the connection information for the current HTTP context.
Ct { get; } Gets the cancellation token that is triggered when the HTTP request is aborted.
Culture { get; } Gets the resolved request culture when localization middleware is enabled.
HasRequestCulture { get; } Gets the resolved request culture when localization middleware is enabled.
HasSession { get; } True if Session middleware is active for this request.
Host { get; set; } The Kestrun host associated with this context.
HttpContext { get; set; } The ASP.NET Core HTTP context associated with this Kestrun context.
Items { get; } Gets the collection of key/value pairs associated with the current HTTP context.
LocalizedStrings { get; } Gets the localized string table for the resolved culture when localization middleware is enabled.
Logger { get; } The logger associated with the Kestrun host.
MapRouteOptions { get; set; } Gets the route options associated with this response.
Parameters { get; } A dictionary to hold parameters passed by user for use within the KestrunContext.
Request { get; set; } The Kestrun request associated with this context.
Response { get; } The Kestrun response associated with this context.
Session { get; } Returns the ASP.NET Core session if the Session middleware is active; otherwise null.
Strings { get; } Gets the localized string table for the resolved culture when localization middleware is enabled.
TraceIdentifier { get; set; } Gets the trace identifier for the current HTTP context.
User { get; } Gets the user associated with the current HTTP context.
BroadcastEvent(…) Synchronous wrapper for BroadcastEventAsync.
BroadcastEventAsync(…) Asynchronously broadcasts a custom event to all connected SignalR clients using the IRealtimeBroadcaster service.
BroadcastLog(…) Synchronous wrapper for BroadcastLogAsync.
BroadcastLogAsync(…) Asynchronously broadcasts a log message to all connected SignalR clients using the IRealtimeBroadcaster service.
BroadcastToGroup(…) Synchronous wrapper for BroadcastToGroupAsync.
BroadcastToGroupAsync(…) Asynchronously broadcasts a message to a specific group of SignalR clients using the IRealtimeBroadcaster service.
Challenge(…) Synchronous wrapper for HttpContext.ChallengeAsync. (3 methods)
ChallengeAsync(…) Asynchronous wrapper for HttpContext.ChallengeAsync using a Hashtable for properties.
SignOut(…) Synchronous wrapper for HttpContext.SignOutAsync. (3 methods)
StartSse() Starts a Server-Sent Events (SSE) response by setting the appropriate headers.
TryGetSession(…) Try pattern to get session without exceptions.
WriteSseEvent(…) Synchronous wrapper for WriteSseEventAsync.
WriteSseEventAsync(…) Writes a Server-Sent Event (SSE) to the response stream.

See Also