Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

JsonResult Class

Definition

Namespace:
Microsoft.AspNetCore.Mvc
Assembly:
Microsoft.AspNetCore.Mvc.Formatters.Json.dll
Assembly:
Microsoft.AspNetCore.Mvc.Core.dll
Package:
Microsoft.AspNetCore.Mvc.Formatters.Json v1.0.0
Package:
Microsoft.AspNetCore.Mvc.Formatters.Json v1.1.0
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.Mvc.Formatters.Json v2.0.0
Package:
Microsoft.AspNetCore.Mvc.Formatters.Json v2.1.0
Package:
Microsoft.AspNetCore.Mvc.Formatters.Json v2.2.0
Package:
Microsoft.AspNetCore.App.Ref v3.0.1
Package:
Microsoft.AspNetCore.App.Ref v3.1.10
Package:
Microsoft.AspNetCore.App.Ref v5.0.0
Package:
Microsoft.AspNetCore.App.Ref v6.0.36
Package:
Microsoft.AspNetCore.App.Ref v7.0.5
Package:
Microsoft.AspNetCore.App.Ref v8.0.19
Package:
Microsoft.AspNetCore.App.Ref v9.0.8
Source:
JsonResult.cs
Source:
JsonResult.cs
Source:
JsonResult.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

An action result which formats the given object as JSON.

public ref class JsonResult : Microsoft::AspNetCore::Mvc::ActionResult
public ref class JsonResult : Microsoft::AspNetCore::Mvc::ActionResult, Microsoft::AspNetCore::Mvc::IActionResult, Microsoft::AspNetCore::Mvc::Infrastructure::IStatusCodeActionResult
public class JsonResult : Microsoft.AspNetCore.Mvc.ActionResult
public class JsonResult : Microsoft.AspNetCore.Mvc.ActionResult, Microsoft.AspNetCore.Mvc.IActionResult, Microsoft.AspNetCore.Mvc.Infrastructure.IStatusCodeActionResult
type JsonResult = class
 inherit ActionResult
type JsonResult = class
 inherit ActionResult
 interface IStatusCodeActionResult
 interface IActionResult
type JsonResult = class
 inherit ActionResult
 interface IActionResult
 interface IStatusCodeActionResult
Public Class JsonResult
Inherits ActionResult
Public Class JsonResult
Inherits ActionResult
Implements IActionResult, IStatusCodeActionResult
Inheritance
JsonResult
Implements

Constructors

Name Description
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

Name Description
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

Name Description
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


Feedback

Was this page helpful?