Results 类

定义

IResult工厂。

public static class Results
type Results = class
Public Class Results
继承
Results

属性

Empty

生成空的结果响应,在执行时不会执行任何操作。

Extensions

为外部库提供容器,以使用自己的示例扩展默认 Results 集。

方法

Accepted(String, Object)

生成 Status202Accepted 响应。

Accepted<TValue>(String, TValue)

生成 Status202Accepted 响应。

AcceptedAtRoute(String, Object, Object)

生成 Status202Accepted 响应。

AcceptedAtRoute(String, RouteValueDictionary, Object)

生成 Status202Accepted 响应。

AcceptedAtRoute<TValue>(String, Object, TValue)

生成 Status202Accepted 响应。

AcceptedAtRoute<TValue>(String, RouteValueDictionary, TValue)

生成 Status202Accepted 响应。

BadRequest(Object)

生成 Status400BadRequest 响应。

BadRequest<TValue>(TValue)

生成 Status400BadRequest 响应。

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

将字节数组内容写入响应。

这支持范围请求(如果范围不满足,Status206PartialContentStatus416RangeNotSatisfiable)。

此 API 是 File(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)的别名。

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

将字节数组内容写入响应。

这支持范围请求(如果范围不满足,Status206PartialContentStatus416RangeNotSatisfiable)。

Challenge(AuthenticationProperties, IList<String>)

创建在执行时调用 ChallengeAsync(HttpContext, String, AuthenticationProperties)IResult

此方法的行为取决于正在使用 IAuthenticationServiceStatus401UnauthorizedStatus403Forbidden 可能是状态结果之一。

Conflict(Object)

生成 Status409Conflict 响应。

Conflict<TValue>(TValue)

生成 Status409Conflict 响应。

Content(String, MediaTypeHeaderValue)

content 字符串写入 HTTP 响应。

Content(String, String, Encoding)

content 字符串写入 HTTP 响应。

这相当于 Text(String, String, Encoding)

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

content 字符串写入 HTTP 响应。

这相当于 Text(String, String, Encoding, Nullable<Int32>)

Created()

生成 Status201Created 响应。

Created(String, Object)

生成 Status201Created 响应。

Created(Uri, Object)

生成 Status201Created 响应。

Created<TValue>(String, TValue)

生成 Status201Created 响应。

Created<TValue>(Uri, TValue)

生成 Status201Created 响应。

CreatedAtRoute(String, Object, Object)

生成 Status201Created 响应。

CreatedAtRoute(String, RouteValueDictionary, Object)

生成 Status201Created 响应。

CreatedAtRoute<TValue>(String, Object, TValue)

生成 Status201Created 响应。

CreatedAtRoute<TValue>(String, RouteValueDictionary, TValue)

生成 Status201Created 响应。

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

将字节数组内容写入响应。

这支持范围请求(如果范围不满足,Status206PartialContentStatus416RangeNotSatisfiable)。

此 API 是 Bytes(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)的别名。

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

将指定的 Stream 写入响应。

这支持范围请求(如果范围不满足,Status206PartialContentStatus416RangeNotSatisfiable)。

此 API 是 Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)的别名。

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

将指定 path 的文件写入响应。

这支持范围请求(如果范围不满足,Status206PartialContentStatus416RangeNotSatisfiable)。

Forbid(AuthenticationProperties, IList<String>)

创建在执行时调用 ForbidAsync(HttpContext, String, AuthenticationProperties)IResult

默认情况下,执行此结果将返回 Status403Forbidden。 某些身份验证方案(如 Cookie)会将 Status403Forbidden 转换为重定向以显示登录页。

InternalServerError()

生成 Status500InternalServerError 响应。

InternalServerError<TValue>(TValue)

生成 Status500InternalServerError 响应。

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

创建将指定 data 对象序列化为 JSON 的 IResult

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

创建将指定 data 对象序列化为 JSON 的 IResult

Json(Object, Type, JsonSerializerContext, String, Nullable<Int32>)

创建将指定 data 对象序列化为 JSON 的 IResult

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

创建将指定 data 对象序列化为 JSON 的 IResult

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

创建将指定 data 对象序列化为 JSON 的 IResult

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

创建将指定 data 对象序列化为 JSON 的 IResult

LocalRedirect(String, Boolean, Boolean)

重定向到指定的 localUrl

NoContent()

生成 Status204NoContent 响应。

NotFound(Object)

生成 Status404NotFound 响应。

NotFound<TValue>(TValue)

生成 Status404NotFound 响应。

Ok(Object)

生成 Status200OK 响应。

Ok<TValue>(TValue)

生成 Status200OK 响应。

Problem(ProblemDetails)

生成 ProblemDetails 响应。

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

生成 ProblemDetails 响应。

Redirect(String, Boolean, Boolean)

重定向到指定的 url

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

重定向到指定的路由。

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

重定向到指定的路由。

SignIn(ClaimsPrincipal, AuthenticationProperties, String)

创建在执行时调用 SignInAsync(HttpContext, String, ClaimsPrincipal, AuthenticationProperties)IResult

SignOut(AuthenticationProperties, IList<String>)

创建在执行时调用 SignOutAsync(HttpContext, String, AuthenticationProperties)IResult

StatusCode(Int32)

通过指定 statusCode创建 IResult 对象。

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

允许直接写入响应正文。

这支持范围请求(如果范围不满足,Status206PartialContentStatus416RangeNotSatisfiable)。

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

将指定 PipeReader 的内容写入响应。

这支持范围请求(如果范围不满足,Status206PartialContentStatus416RangeNotSatisfiable)。

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

将指定的 Stream 写入响应。

这支持范围请求(如果范围不满足,Status206PartialContentStatus416RangeNotSatisfiable)。

此 API 是 File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)的别名。

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

utf8Content UTF-8 编码的文本写入 HTTP 响应。

Text(String, String, Encoding)

content 字符串写入 HTTP 响应。

这是 Content(String, String, Encoding)的别名。

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

content 字符串写入 HTTP 响应。

这是 Content(String, String, Encoding, Nullable<Int32>)的别名。

Unauthorized()

生成 Status401Unauthorized 响应。

UnprocessableEntity(Object)

生成 Status422UnprocessableEntity 响应。

UnprocessableEntity<TValue>(TValue)

生成 Status422UnprocessableEntity 响应。

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

生成具有 HttpValidationProblemDetails 值的 Status400BadRequest 响应。

适用于