Class JsonResponse<T>
Writes a generated response variant's body as JSON with the given status, through the app's
JsonOptions (so the generated source-gen context serializes it). Resolving the
type info there, rather than through TypedResults.Json, keeps the generated code free of
reflection warnings under Native AOT.
public sealed class JsonResponse<T> : IResult
Type Parameters
T
- Inheritance
-
JsonResponse<T>
- Implements
- Inherited Members
Constructors
JsonResponse(T, int)
Writes a generated response variant's body as JSON with the given status, through the app's
JsonOptions (so the generated source-gen context serializes it). Resolving the
type info there, rather than through TypedResults.Json, keeps the generated code free of
reflection warnings under Native AOT.
public JsonResponse(T value, int status)
Parameters
valueTstatusint
Methods
ExecuteAsync(HttpContext)
Write an HTTP response reflecting the result.
public Task ExecuteAsync(HttpContext httpContext)
Parameters
httpContextHttpContextThe HttpContext for the current request.
Returns
- Task
A task that represents the asynchronous execute operation.