Table of Contents

Class JsonResult<T>

Namespace
System.Web.Http.Results
Assembly
System.Web.Http.dll

Represents an action result that returns an OK response with JSON data.

public class JsonResult<T> : IHttpActionResult

Type Parameters

T

The type of content in the entity body.

Inheritance
JsonResult<T>
Implements
Inherited Members

Constructors

JsonResult(T, JsonSerializerSettings, Encoding, HttpRequestMessage)

Initializes a new instance of the JsonResult<T> class with the values provided.

public JsonResult(T content, JsonSerializerSettings serializerSettings, Encoding encoding, HttpRequestMessage request)

Parameters

content T

The content value to serialize in the entity body.

serializerSettings JsonSerializerSettings

The serializer settings.

encoding Encoding

The content encoding.

request HttpRequestMessage

The request message which led to this result.

JsonResult(T, JsonSerializerSettings, Encoding, ApiController)

Initializes a new instance of the JsonResult<T> class with the values provided.

public JsonResult(T content, JsonSerializerSettings serializerSettings, Encoding encoding, ApiController controller)

Parameters

content T

The content value to serialize in the entity body.

serializerSettings JsonSerializerSettings

The serializer settings.

encoding Encoding

The content encoding.

controller ApiController

The controller from which to obtain the dependencies needed for execution.

Properties

Content

Gets the content value to serialize in the entity body.

public T Content { get; }

Property Value

T

The content value to serialize in the entity body.

Encoding

Gets the content encoding.

public Encoding Encoding { get; }

Property Value

Encoding

The content encoding.

Request

Gets the request message which led to this result.

public HttpRequestMessage Request { get; }

Property Value

HttpRequestMessage

The request message which led to this result.

SerializerSettings

Gets the serializer settings.

public JsonSerializerSettings SerializerSettings { get; }

Property Value

JsonSerializerSettings

The serializer settings.

Methods

ExecuteAsync(CancellationToken)

Creates a response message asynchronously.

public virtual Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<HttpResponseMessage>

A task that, when completed, contains the response message.