Table of Contents

Class NerdbankJsonMvcBuilderExtensions

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
Nerdbank.Json.AspNetCoreMvcFormatter.dll

Extension methods that register the Nerdbank.Json MVC input and output formatters.

public static class NerdbankJsonMvcBuilderExtensions
Inheritance
NerdbankJsonMvcBuilderExtensions
Inherited Members

Methods

AddNerdbankJsonFormatters(IMvcBuilder, JsonSerializer, ITypeShapeProvider, Action<NerdbankJsonFormatterOptions>?)

Adds the Nerdbank.Json input and output formatters to an MVC pipeline.

public static IMvcBuilder AddNerdbankJsonFormatters(this IMvcBuilder builder, JsonSerializer serializer, ITypeShapeProvider shapeProvider, Action<NerdbankJsonFormatterOptions>? configure = null)

Parameters

builder IMvcBuilder

The MVC builder (for example from AddControllers).

serializer JsonSerializer

The serializer the formatters use.

shapeProvider ITypeShapeProvider

The source-generated shape provider that describes every model type read or written.

configure Action<NerdbankJsonFormatterOptions>

An optional callback to configure registration behavior.

Returns

IMvcBuilder

The builder for chaining.

Remarks

By default the formatters are inserted at the front of the formatter collections so they win content negotiation for JSON media types, but the built-in System.Text.Json formatters are left in place. Set ReplaceSystemTextJsonFormatters to remove them entirely.

AddNerdbankJsonFormatters(IMvcCoreBuilder, JsonSerializer, ITypeShapeProvider, Action<NerdbankJsonFormatterOptions>?)

Adds the Nerdbank.Json input and output formatters to an MVC-Core pipeline.

public static IMvcCoreBuilder AddNerdbankJsonFormatters(this IMvcCoreBuilder builder, JsonSerializer serializer, ITypeShapeProvider shapeProvider, Action<NerdbankJsonFormatterOptions>? configure = null)

Parameters

builder IMvcCoreBuilder

The MVC-Core builder (for example from AddControllersAsServices or AddMvcCore).

serializer JsonSerializer

The serializer the formatters use.

shapeProvider ITypeShapeProvider

The source-generated shape provider that describes every model type read or written.

configure Action<NerdbankJsonFormatterOptions>

An optional callback to configure registration behavior.

Returns

IMvcCoreBuilder

The builder for chaining.

Remarks

By default the formatters are inserted at the front of the formatter collections so they win content negotiation for JSON media types, but the built-in System.Text.Json formatters are left in place. Set ReplaceSystemTextJsonFormatters to remove them entirely.