TypedResults Class

Definition

A typed factory for IResult types in Microsoft.AspNetCore.Http.HttpResults.

public static class TypedResults
type TypedResults = class
Public Class TypedResults
Inheritance
TypedResults

Properties

Empty

Produces an empty result response, that when executed will do nothing.

Extensions

Provides a container for external libraries to extend the default TypedResults set with their own samples.

Methods

Accepted(String)

Produces a Status202Accepted response.

Accepted(Uri)

Produces a Status202Accepted response.

Accepted<TValue>(String, TValue)

Produces a Status202Accepted response.

Accepted<TValue>(Uri, TValue)

Produces a Status202Accepted response.

AcceptedAtRoute(String, Object)

Produces a Status202Accepted response.

AcceptedAtRoute(String, RouteValueDictionary)

Produces a Status202Accepted response.

AcceptedAtRoute<TValue>(TValue, String, Object)

Produces a Status202Accepted response.

AcceptedAtRoute<TValue>(TValue, String, RouteValueDictionary)

Produces a Status202Accepted response.

BadRequest()

Produces a Status400BadRequest response.

BadRequest<TValue>(TValue)

Produces a Status400BadRequest response.

Bytes(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Writes the byte-array content to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

This API is an alias for File(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue).

Bytes(ReadOnlyMemory<Byte>, String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Writes the byte-array content to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

Challenge(AuthenticationProperties, IList<String>)

Creates a ChallengeHttpResult that on execution invokes ChallengeAsync(HttpContext, String, AuthenticationProperties).

The behavior of this method depends on the IAuthenticationService in use. Status401Unauthorized and Status403Forbidden are among likely status results.

Conflict()

Produces a Status409Conflict response.

Conflict<TValue>(TValue)

Produces a Status409Conflict response.

Content(String, MediaTypeHeaderValue)

Writes the content string to the HTTP response.

Content(String, String, Encoding, Nullable<Int32>)

Writes the content string to the HTTP response.

This is equivalent to Text(String, String, Encoding, Nullable<Int32>).

Content(String, String, Encoding)

Writes the content string to the HTTP response.

This is equivalent to Text(String, String, Encoding).

Created()

Produces a Status201Created response.

Created(String)

Produces a Status201Created response.

Created(Uri)

Produces a Status201Created response.

Created<TValue>(String, TValue)

Produces a Status201Created response.

Created<TValue>(Uri, TValue)

Produces a Status201Created response.

CreatedAtRoute(String, Object)

Produces a Status201Created response.

CreatedAtRoute(String, RouteValueDictionary)

Produces a Status201Created response.

CreatedAtRoute<TValue>(TValue, String, Object)

Produces a Status201Created response.

CreatedAtRoute<TValue>(TValue, String, RouteValueDictionary)

Produces a Status201Created response.

File(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Writes the byte-array content to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

This API is an alias for Bytes(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue).

File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Writes the specified Stream to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

This API is an alias for Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean).

Forbid(AuthenticationProperties, IList<String>)

Creates a ForbidHttpResult that on execution invokes ForbidAsync(HttpContext, String, AuthenticationProperties).

By default, executing this result returns a Status403Forbidden. Some authentication schemes, such as cookies, will convert Status403Forbidden to a redirect to show a login page.

InternalServerError()

Produces a Status500InternalServerError response.

InternalServerError<TValue>(TValue)

Produces a Status500InternalServerError response.

Json<TValue>(TValue, JsonSerializerContext, String, Nullable<Int32>)

Creates a JsonHttpResult<TValue> that serializes the specified data object to JSON.

Json<TValue>(TValue, JsonSerializerOptions, String, Nullable<Int32>)

Creates a JsonHttpResult<TValue> that serializes the specified data object to JSON.

Json<TValue>(TValue, JsonTypeInfo<TValue>, String, Nullable<Int32>)

Creates a JsonHttpResult<TValue> that serializes the specified data object to JSON.

LocalRedirect(String, Boolean, Boolean)

Redirects to the specified localUrl.

NoContent()

Produces a Status204NoContent response.

NotFound()

Produces a Status404NotFound response.

NotFound<TValue>(TValue)

Produces a Status404NotFound response.

Ok()

Produces a Status200OK response.

Ok<TValue>(TValue)

Produces a Status200OK response.

PhysicalFile(String, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Writes the file at the specified path to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

Problem(ProblemDetails)

Produces a ProblemDetails response.

Problem(String, String, Nullable<Int32>, String, String, IDictionary<String,Object>)

Produces a ProblemDetails response.

Problem(String, String, Nullable<Int32>, String, String, IEnumerable<KeyValuePair<String,Object>>)

Produces a ProblemDetails response.

Redirect(String, Boolean, Boolean)

Redirects to the specified url.

RedirectToRoute(String, Object, Boolean, Boolean, String)

Redirects to the specified route.

RedirectToRoute(String, RouteValueDictionary, Boolean, Boolean, String)

Redirects to the specified route.

SignIn(ClaimsPrincipal, AuthenticationProperties, String)

Creates a SignInHttpResult that on execution invokes SignInAsync(HttpContext, String, ClaimsPrincipal, AuthenticationProperties).

SignOut(AuthenticationProperties, IList<String>)

Creates a SignOutHttpResult that on execution invokes SignOutAsync(HttpContext, String, AuthenticationProperties).

StatusCode(Int32)

Creates a StatusCodeHttpResult object by specifying a statusCode.

Stream(Func<Stream,Task>, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Allows writing directly to the response body.

Stream(PipeReader, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Writes the contents of the specified PipeReader to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Writes the specified Stream to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

This API is an alias for File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean).

Text(ReadOnlySpan<Byte>, String, Nullable<Int32>)

Writes the utf8Content UTF8 text content to the HTTP response.

Text(String, String, Encoding, Nullable<Int32>)

Writes the content string to the HTTP response.

This is an alias for Content(String, String, Encoding, Nullable<Int32>).

Text(String, String, Encoding)

Writes the content string to the HTTP response.

This is an alias for Content(String, String, Encoding).

Unauthorized()

Produces a Status401Unauthorized response.

UnprocessableEntity()

Produces a Status422UnprocessableEntity response.

UnprocessableEntity<TValue>(TValue)

Produces a Status422UnprocessableEntity response.

ValidationProblem(IDictionary<String,String[]>, String, String, String, String, IDictionary<String,Object>)

Produces a Status400BadRequest response with an HttpValidationProblemDetails value.

ValidationProblem(IEnumerable<KeyValuePair<String,String[]>>, String, String, String, String, IEnumerable<KeyValuePair<String,Object>>)

Produces a Status400BadRequest response with an HttpValidationProblemDetails value.

VirtualFile(String, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Writes the file at the specified path to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

Applies to