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
builderIMvcBuilderThe MVC builder (for example from
AddControllers).serializerJsonSerializerThe serializer the formatters use.
shapeProviderITypeShapeProviderThe source-generated shape provider that describes every model type read or written.
configureAction<NerdbankJsonFormatterOptions>An optional callback to configure registration behavior.
Returns
- IMvcBuilder
The
builderfor 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
builderIMvcCoreBuilderThe MVC-Core builder (for example from
AddControllersAsServicesorAddMvcCore).serializerJsonSerializerThe serializer the formatters use.
shapeProviderITypeShapeProviderThe source-generated shape provider that describes every model type read or written.
configureAction<NerdbankJsonFormatterOptions>An optional callback to configure registration behavior.
Returns
- IMvcCoreBuilder
The
builderfor 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.