JsonViewComponentResult Class

Summary

An [Microsoft.AspNet.Mvc.IViewComponentResult](Microsoft.AspNet.Mvc.IViewComponentResult.yml) which renders JSON text when executed.

Syntax

public class JsonViewComponentResult : IViewComponentResult

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.JsonViewComponentResult

Constructors

JsonViewComponentResult(System.Object)

Initializes a new [Microsoft.AspNet.Mvc.JsonViewComponentResult](Microsoft.AspNet.Mvc.JsonViewComponentResult.yml).

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

Initializes a new [Microsoft.AspNet.Mvc.JsonViewComponentResult](Microsoft.AspNet.Mvc.JsonViewComponentResult.yml).

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

Initializes a new [Microsoft.AspNet.Mvc.JsonViewComponentResult](Microsoft.AspNet.Mvc.JsonViewComponentResult.yml).

Arguments:
  • value (System.Object) – The value to format as JSON text.
  • formatter (Microsoft.AspNet.Mvc.JsonOutputFormatter) – The [Microsoft.AspNet.Mvc.JsonOutputFormatter](Microsoft.AspNet.Mvc.JsonOutputFormatter.yml) to use.
public JsonViewComponentResult(object value, JsonOutputFormatter formatter)

Properties

Formatter()

Gets the formatter.

Return type:Microsoft.AspNet.Mvc.JsonOutputFormatter
public JsonOutputFormatter Formatter { get; }
Value()

Gets the value.

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

Methods

Execute(Microsoft.AspNet.Mvc.ViewComponentContext)

Renders JSON text to the output.

Arguments:
public void Execute(ViewComponentContext context)
ExecuteAsync(Microsoft.AspNet.Mvc.ViewComponentContext)

Renders JSON text to the output.

Arguments:
Return type:

System.Threading.Tasks.Task

Returns:

A completed [System.Threading.Tasks.Task]().

public Task ExecuteAsync(ViewComponentContext context)