Share via


HttpResponseJsonExtensions.WriteAsJsonAsync Method

Definition

Overloads

WriteAsJsonAsync(HttpResponse, Object, Type, CancellationToken)

Write the specified value as JSON to the response body. The response content-type will be set to application/json; charset=utf-8.

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

Write the specified value as JSON to the response body. The response content-type will be set to the specified content-type.

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

Write the specified value as JSON to the response body. The response content-type will be set to application/json; charset=utf-8.

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

Write the specified value as JSON to the response body. The response content-type will be set to the specified content-type.

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

Write the specified value as JSON to the response body. The response content-type will be set to the specified content-type.

WriteAsJsonAsync<TValue>(HttpResponse, TValue, CancellationToken)

Write the specified value as JSON to the response body. The response content-type will be set to application/json; charset=utf-8.

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

Write the specified value as JSON to the response body. The response content-type will be set to application/json; charset=utf-8.

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

Write the specified value as JSON to the response body. The response content-type will be set to the specified content-type.

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

Write the specified value as JSON to the response body. The response content-type will be set to the specified content-type.

WriteAsJsonAsync(HttpResponse, Object, Type, CancellationToken)

Source:
HttpResponseJsonExtensions.cs

Write the specified value as JSON to the response body. The response content-type will be set to 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

Parameters

response
HttpResponse

The response to write JSON to.

value
Object

The value to write as JSON.

type
Type

The type of object to write.

cancellationToken
CancellationToken

A CancellationToken used to cancel the operation.

Returns

The task object representing the asynchronous operation.

Applies to

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

Source:
HttpResponseJsonExtensions.cs

Write the specified value as JSON to the response body. The response content-type will be set to the specified content-type.

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

Parameters

response
HttpResponse

The response to write JSON to.

value
Object

The value to write as JSON.

jsonTypeInfo
JsonTypeInfo

Metadata about the type to convert.

contentType
String

The content-type to set on the response.

cancellationToken
CancellationToken

A CancellationToken used to cancel the operation.

Returns

The task object representing the asynchronous operation.

Applies to

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

Source:
HttpResponseJsonExtensions.cs

Write the specified value as JSON to the response body. The response content-type will be set to 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

Parameters

response
HttpResponse

The response to write JSON to.

value
Object

The value to write as JSON.

type
Type

The type of object to write.

options
JsonSerializerOptions

The serializer options to use when serializing the value.

cancellationToken
CancellationToken

A CancellationToken used to cancel the operation.

Returns

The task object representing the asynchronous operation.

Applies to

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

Source:
HttpResponseJsonExtensions.cs

Write the specified value as JSON to the response body. The response content-type will be set to the specified content-type.

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

Parameters

response
HttpResponse

The response to write JSON to.

value
Object

The value to write as JSON.

type
Type

The type of object to write.

options
JsonSerializerOptions

The serializer options to use when serializing the value.

contentType
String

The content-type to set on the response.

cancellationToken
CancellationToken

A CancellationToken used to cancel the operation.

Returns

The task object representing the asynchronous operation.

Applies to

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

Source:
HttpResponseJsonExtensions.cs

Write the specified value as JSON to the response body. The response content-type will be set to the specified content-type.

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

Parameters

response
HttpResponse

The response to write JSON to.

value
Object

The value to write as JSON.

type
Type

The type of object to write.

context
JsonSerializerContext

A metadata provider for serializable types.

contentType
String

The content-type to set on the response.

cancellationToken
CancellationToken

A CancellationToken used to cancel the operation.

Returns

The task object representing the asynchronous operation.

Applies to

WriteAsJsonAsync<TValue>(HttpResponse, TValue, CancellationToken)

Source:
HttpResponseJsonExtensions.cs

Write the specified value as JSON to the response body. The response content-type will be set to 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

Type Parameters

TValue

The type of object to write.

Parameters

response
HttpResponse

The response to write JSON to.

value
TValue

The value to write as JSON.

cancellationToken
CancellationToken

A CancellationToken used to cancel the operation.

Returns

The task object representing the asynchronous operation.

Applies to

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

Source:
HttpResponseJsonExtensions.cs

Write the specified value as JSON to the response body. The response content-type will be set to 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

Type Parameters

TValue

The type of object to write.

Parameters

response
HttpResponse

The response to write JSON to.

value
TValue

The value to write as JSON.

options
JsonSerializerOptions

The serializer options to use when serializing the value.

cancellationToken
CancellationToken

A CancellationToken used to cancel the operation.

Returns

The task object representing the asynchronous operation.

Applies to

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

Source:
HttpResponseJsonExtensions.cs

Write the specified value as JSON to the response body. The response content-type will be set to the specified content-type.

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

Type Parameters

TValue

The type of object to write.

Parameters

response
HttpResponse

The response to write JSON to.

value
TValue

The value to write as JSON.

options
JsonSerializerOptions

The serializer options to use when serializing the value.

contentType
String

The content-type to set on the response.

cancellationToken
CancellationToken

A CancellationToken used to cancel the operation.

Returns

The task object representing the asynchronous operation.

Applies to

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

Source:
HttpResponseJsonExtensions.cs

Write the specified value as JSON to the response body. The response content-type will be set to the specified content-type.

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

Type Parameters

TValue

The type of object to write.

Parameters

response
HttpResponse

The response to write JSON to.

value
TValue

The value to write as JSON.

jsonTypeInfo
JsonTypeInfo<TValue>

Metadata about the type to convert.

contentType
String

The content-type to set on the response.

cancellationToken
CancellationToken

A CancellationToken used to cancel the operation.

Returns

The task object representing the asynchronous operation.

Applies to