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(…) Represents the context for a Kestrun request, including the request, response, HTTP context, and host.
Ct { get; } Gets the cancellation token that is triggered when the HTTP request is aborted.
HasSession { get; } True if Session middleware is active for this request.
HttpContext { get; set; } The associated HTTP context.
Items { get; } Gets the collection of key/value pairs associated with the current HTTP context.
Request { get; set; } The Kestrun request.
Response { get; set; } The Kestrun response.
Session { get; } Returns the ASP.NET Core session if the Session middleware is active; otherwise null.
User { get; } Gets the user associated with the current HTTP context.
TryGetSession(…) Try pattern to get session without exceptions.

See Also