Class JsonResult<T>
Represents an action result that returns an OK response with JSON data.
public class JsonResult<T> : IHttpActionResult
Type Parameters
TThe 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
contentTThe content value to serialize in the entity body.
serializerSettingsJsonSerializerSettingsThe serializer settings.
encodingEncodingThe content encoding.
requestHttpRequestMessageThe 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
contentTThe content value to serialize in the entity body.
serializerSettingsJsonSerializerSettingsThe serializer settings.
encodingEncodingThe content encoding.
controllerApiControllerThe 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
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<HttpResponseMessage>
A task that, when completed, contains the response message.