HttpResponseJsonExtensions.WriteAsJsonAsync 方法

定义

重载

WriteAsJsonAsync(HttpResponse, Object, Type, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为 application/json; charset=utf-8

WriteAsJsonAsync(HttpResponse, Object, JsonTypeInfo, String, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为指定的内容类型。

WriteAsJsonAsync(HttpResponse, Object, Type, JsonSerializerOptions, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为 application/json; charset=utf-8

WriteAsJsonAsync(HttpResponse, Object, Type, JsonSerializerOptions, String, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为指定的内容类型。

WriteAsJsonAsync(HttpResponse, Object, Type, JsonSerializerContext, String, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为指定的内容类型。

WriteAsJsonAsync<TValue>(HttpResponse, TValue, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为 application/json; charset=utf-8

WriteAsJsonAsync<TValue>(HttpResponse, TValue, JsonSerializerOptions, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为 application/json; charset=utf-8

WriteAsJsonAsync<TValue>(HttpResponse, TValue, JsonSerializerOptions, String, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为指定的内容类型。

WriteAsJsonAsync<TValue>(HttpResponse, TValue, JsonTypeInfo<TValue>, String, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为指定的内容类型。

WriteAsJsonAsync(HttpResponse, Object, Type, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为 application/json; charset=utf-8

public static System.Threading.Tasks.Task WriteAsJsonAsync (this Microsoft.AspNetCore.Http.HttpResponse response, object? value, Type type, System.Threading.CancellationToken cancellationToken = default);
static member WriteAsJsonAsync : Microsoft.AspNetCore.Http.HttpResponse * obj * Type * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function WriteAsJsonAsync (response As HttpResponse, value As Object, type As Type, Optional cancellationToken As CancellationToken = Nothing) As Task

参数

response
HttpResponse

要向其写入 JSON 的响应。

value
Object

要写入为 JSON 的值。

type
Type

要写入的对象的类型。

cancellationToken
CancellationToken

CancellationToken用于取消操作的 。

返回

表示异步操作的任务对象。

适用于

WriteAsJsonAsync(HttpResponse, Object, JsonTypeInfo, String, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为指定的内容类型。

public static System.Threading.Tasks.Task WriteAsJsonAsync (this Microsoft.AspNetCore.Http.HttpResponse response, object? value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo, string? contentType = default, System.Threading.CancellationToken cancellationToken = default);
static member WriteAsJsonAsync : Microsoft.AspNetCore.Http.HttpResponse * obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function WriteAsJsonAsync (response As HttpResponse, value As Object, jsonTypeInfo As JsonTypeInfo, Optional contentType As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task

参数

response
HttpResponse

要向其写入 JSON 的响应。

value
Object

要写入为 JSON 的值。

jsonTypeInfo
JsonTypeInfo

有关要转换的类型的元数据。

contentType
String

要对响应设置的内容类型。

cancellationToken
CancellationToken

CancellationToken用于取消操作的 。

返回

表示异步操作的任务对象。

适用于

WriteAsJsonAsync(HttpResponse, Object, Type, JsonSerializerOptions, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为 application/json; charset=utf-8

public static System.Threading.Tasks.Task WriteAsJsonAsync (this Microsoft.AspNetCore.Http.HttpResponse response, object? value, Type type, System.Text.Json.JsonSerializerOptions? options, System.Threading.CancellationToken cancellationToken = default);
static member WriteAsJsonAsync : Microsoft.AspNetCore.Http.HttpResponse * obj * Type * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function WriteAsJsonAsync (response As HttpResponse, value As Object, type As Type, options As JsonSerializerOptions, Optional cancellationToken As CancellationToken = Nothing) As Task

参数

response
HttpResponse

要向其写入 JSON 的响应。

value
Object

要写入为 JSON 的值。

type
Type

要写入的对象的类型。

options
JsonSerializerOptions

序列化值时要使用的序列化程序选项。

cancellationToken
CancellationToken

CancellationToken用于取消操作的 。

返回

表示异步操作的任务对象。

适用于

WriteAsJsonAsync(HttpResponse, Object, Type, JsonSerializerOptions, String, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为指定的内容类型。

public static System.Threading.Tasks.Task WriteAsJsonAsync (this Microsoft.AspNetCore.Http.HttpResponse response, object? value, Type type, System.Text.Json.JsonSerializerOptions? options, string? contentType, System.Threading.CancellationToken cancellationToken = default);
static member WriteAsJsonAsync : Microsoft.AspNetCore.Http.HttpResponse * obj * Type * System.Text.Json.JsonSerializerOptions * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function WriteAsJsonAsync (response As HttpResponse, value As Object, type As Type, options As JsonSerializerOptions, contentType As String, Optional cancellationToken As CancellationToken = Nothing) As Task

参数

response
HttpResponse

要向其写入 JSON 的响应。

value
Object

要写入为 JSON 的值。

type
Type

要写入的对象的类型。

options
JsonSerializerOptions

序列化值时要使用的序列化程序选项。

contentType
String

要对响应设置的内容类型。

cancellationToken
CancellationToken

CancellationToken用于取消操作的 。

返回

表示异步操作的任务对象。

适用于

WriteAsJsonAsync(HttpResponse, Object, Type, JsonSerializerContext, String, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为指定的内容类型。

public static System.Threading.Tasks.Task WriteAsJsonAsync (this Microsoft.AspNetCore.Http.HttpResponse response, object? value, Type type, System.Text.Json.Serialization.JsonSerializerContext context, string? contentType = default, System.Threading.CancellationToken cancellationToken = default);
static member WriteAsJsonAsync : Microsoft.AspNetCore.Http.HttpResponse * obj * Type * System.Text.Json.Serialization.JsonSerializerContext * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function WriteAsJsonAsync (response As HttpResponse, value As Object, type As Type, context As JsonSerializerContext, Optional contentType As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task

参数

response
HttpResponse

要向其写入 JSON 的响应。

value
Object

要写入为 JSON 的值。

type
Type

要写入的对象的类型。

context
JsonSerializerContext

可序列化类型的元数据提供程序。

contentType
String

要对响应设置的内容类型。

cancellationToken
CancellationToken

CancellationToken用于取消操作的 。

返回

表示异步操作的任务对象。

适用于

WriteAsJsonAsync<TValue>(HttpResponse, TValue, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为 application/json; charset=utf-8

public static System.Threading.Tasks.Task WriteAsJsonAsync<TValue> (this Microsoft.AspNetCore.Http.HttpResponse response, TValue value, System.Threading.CancellationToken cancellationToken = default);
static member WriteAsJsonAsync : Microsoft.AspNetCore.Http.HttpResponse * 'Value * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function WriteAsJsonAsync(Of TValue) (response As HttpResponse, value As TValue, Optional cancellationToken As CancellationToken = Nothing) As Task

类型参数

TValue

要写入的对象的类型。

参数

response
HttpResponse

要向其写入 JSON 的响应。

value
TValue

要写入为 JSON 的值。

cancellationToken
CancellationToken

CancellationToken用于取消操作的 。

返回

表示异步操作的任务对象。

适用于

WriteAsJsonAsync<TValue>(HttpResponse, TValue, JsonSerializerOptions, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为 application/json; charset=utf-8

public static System.Threading.Tasks.Task WriteAsJsonAsync<TValue> (this Microsoft.AspNetCore.Http.HttpResponse response, TValue value, System.Text.Json.JsonSerializerOptions? options, System.Threading.CancellationToken cancellationToken = default);
static member WriteAsJsonAsync : Microsoft.AspNetCore.Http.HttpResponse * 'Value * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function WriteAsJsonAsync(Of TValue) (response As HttpResponse, value As TValue, options As JsonSerializerOptions, Optional cancellationToken As CancellationToken = Nothing) As Task

类型参数

TValue

要写入的对象的类型。

参数

response
HttpResponse

要向其写入 JSON 的响应。

value
TValue

要写入为 JSON 的值。

options
JsonSerializerOptions

序列化值时要使用的序列化程序选项。

cancellationToken
CancellationToken

CancellationToken用于取消操作的 。

返回

表示异步操作的任务对象。

适用于

WriteAsJsonAsync<TValue>(HttpResponse, TValue, JsonSerializerOptions, String, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为指定的内容类型。

public static System.Threading.Tasks.Task WriteAsJsonAsync<TValue> (this Microsoft.AspNetCore.Http.HttpResponse response, TValue value, System.Text.Json.JsonSerializerOptions? options, string? contentType, System.Threading.CancellationToken cancellationToken = default);
static member WriteAsJsonAsync : Microsoft.AspNetCore.Http.HttpResponse * 'Value * System.Text.Json.JsonSerializerOptions * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function WriteAsJsonAsync(Of TValue) (response As HttpResponse, value As TValue, options As JsonSerializerOptions, contentType As String, Optional cancellationToken As CancellationToken = Nothing) As Task

类型参数

TValue

要写入的对象的类型。

参数

response
HttpResponse

要向其写入 JSON 的响应。

value
TValue

要写入为 JSON 的值。

options
JsonSerializerOptions

序列化值时要使用的序列化程序选项。

contentType
String

要对响应设置的内容类型。

cancellationToken
CancellationToken

CancellationToken用于取消操作的 。

返回

表示异步操作的任务对象。

适用于

WriteAsJsonAsync<TValue>(HttpResponse, TValue, JsonTypeInfo<TValue>, String, CancellationToken)

将指定值作为 JSON 写入响应正文。 响应内容类型将设置为指定的内容类型。

public static System.Threading.Tasks.Task WriteAsJsonAsync<TValue> (this Microsoft.AspNetCore.Http.HttpResponse response, TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo, string? contentType = default, System.Threading.CancellationToken cancellationToken = default);
static member WriteAsJsonAsync : Microsoft.AspNetCore.Http.HttpResponse * 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function WriteAsJsonAsync(Of TValue) (response As HttpResponse, value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue), Optional contentType As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task

类型参数

TValue

要写入的对象的类型。

参数

response
HttpResponse

要向其写入 JSON 的响应。

value
TValue

要写入为 JSON 的值。

jsonTypeInfo
JsonTypeInfo<TValue>

有关要转换的类型的元数据。

contentType
String

要对响应设置的内容类型。

cancellationToken
CancellationToken

CancellationToken用于取消操作的 。

返回

表示异步操作的任务对象。

适用于