JsonResult Class

Summary

An action result which formats the given object as JSON.

Syntax

public class JsonResult : ActionResult, IActionResult

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.JsonResult

Fields

DefaultContentTypes()

The list of content-types used for formatting when [Microsoft.AspNet.Mvc.JsonResult.ContentTypes](Microsoft.AspNet.Mvc.JsonResult.yml) is null or empty.

public static readonly IReadOnlyList<MediaTypeHeaderValue> DefaultContentTypes

Constructors

JsonResult(System.Object)

Creates a new [Microsoft.AspNet.Mvc.JsonResult](Microsoft.AspNet.Mvc.JsonResult.yml) with the given <paramref name=”value” />.

Arguments:
  • value (System.Object) – The value to format as JSON.
public JsonResult(object value)
JsonResult(System.Object, JsonSerializerSettings)

Creates a new [Microsoft.AspNet.Mvc.JsonResult](Microsoft.AspNet.Mvc.JsonResult.yml) with the given <paramref name=”value” />.

Arguments:
  • value (System.Object) – The value to format as JSON.
  • serializerSettings (JsonSerializerSettings) – The @!:JsonSerializerSettings- to be used by the formatter.
public JsonResult(object value, JsonSerializerSettings serializerSettings)
JsonResult(System.Object, Microsoft.AspNet.Mvc.IOutputFormatter)

Creates a new [Microsoft.AspNet.Mvc.JsonResult](Microsoft.AspNet.Mvc.JsonResult.yml) with the given <paramref name=”value” />.

Arguments:
public JsonResult(object value, IOutputFormatter formatter)

Properties

ContentTypes()

Gets or sets the list of supported Content-Types.

Return type:System.Collections.Generic.IList{MediaTypeHeaderValue}
public IList<MediaTypeHeaderValue> ContentTypes { get; set; }
Formatter()

Gets or sets the formatter.

Return type:Microsoft.AspNet.Mvc.IOutputFormatter
public IOutputFormatter Formatter { get; set; }
StatusCode()

Gets or sets the HTTP status code.

Return type:System.Nullable{System.Int32}
public int ? StatusCode { get; set; }
Value()

Gets or sets the value to be formatted.

Return type:System.Object
public object Value { get; set; }

Methods

ExecuteResultAsync(Microsoft.AspNet.Mvc.ActionContext)
Arguments:
Return type:

System.Threading.Tasks.Task

public override Task ExecuteResultAsync(ActionContext context)