Skip to content
Documentation

OutputFormatterCanWriteContextExtensions Class

Provides extension methods for Microsoft.AspNetCore.Mvc.Formatters.OutputFormatterCanWriteContext related to serializer resolution.

public static class OutputFormatterCanWriteContextExtensions

Inheritance System.Object 🡒 OutputFormatterCanWriteContextExtensions

OutputFormatterCanWriteContextExtensions.TrySetSerializer(this OutputFormatterCanWriteContext, Type) Method

Section titled “OutputFormatterCanWriteContextExtensions.TrySetSerializer(this OutputFormatterCanWriteContext, Type) Method”

Attempts to resolve an ISerializer for the response based on the endpoint and request media types, and stores it in the HttpContext.

public static bool TrySetSerializer(this Microsoft.AspNetCore.Mvc.Formatters.OutputFormatterCanWriteContext context, System.Type? type=null);

context Microsoft.AspNetCore.Mvc.Formatters.OutputFormatterCanWriteContext

The Microsoft.AspNetCore.Mvc.Formatters.OutputFormatterCanWriteContext for the current response.

type System.Type

The type to serialize. If null, the type is inferred from the context.

System.Boolean
true if a matching serializer was found and set; otherwise, false.

© 2026 Volue.Version v0.6.38017 November 2026