JsonResult Class

Definition

An action result which formats the given object as JSON.

C#
public class JsonResult : Microsoft.AspNetCore.Mvc.ActionResult
C#
public class JsonResult : Microsoft.AspNetCore.Mvc.ActionResult, Microsoft.AspNetCore.Mvc.IActionResult, Microsoft.AspNetCore.Mvc.Infrastructure.IStatusCodeActionResult
Inheritance
JsonResult
Implements

Constructors

JsonResult(Object, JsonSerializerSettings)

Creates a new JsonResult with the given value.

JsonResult(Object, Object)

Creates a new JsonResult with the given value.

JsonResult(Object)

Creates a new JsonResult with the given value.

Properties

ContentType

Gets or sets the MediaTypeHeaderValue representing the Content-Type header of the response.

SerializerSettings

Gets or sets the serializer settings.

When using System.Text.Json, this should be an instance of JsonSerializerOptions

When using Newtonsoft.Json, this should be an instance of JsonSerializerSettings.

StatusCode

Gets or sets the HTTP status code.

Value

Gets or sets the value to be formatted.

Methods

ExecuteResult(ActionContext)

Executes the result operation of the action method synchronously. This method is called by MVC to process the result of an action method.

(Inherited from ActionResult)
ExecuteResultAsync(ActionContext)

Executes the result operation of the action method asynchronously. This method is called by MVC to process the result of an action method.

Applies to

Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0