Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missmatch of application/json strings in ExampleFilters #253

Open
mange89b opened this issue Aug 19, 2024 · 0 comments
Open

Missmatch of application/json strings in ExampleFilters #253

mange89b opened this issue Aug 19, 2024 · 0 comments

Comments

@mange89b
Copy link

mange89b commented Aug 19, 2024

Two different strings in two different files make you always to get FormatterNotFoundException "OutputFormatter not found for 'application/json; charset=utf-8'" error when to running MVC

ExamplesConverter.cs

private static readonly MediaTypeHeaderValue ApplicationJson = MediaTypeHeaderValue.Parse("application/json; charset=utf-8");

MvcOutputFormatter.cs

private string SerializeWithoutMvc(T value, MediaTypeHeaderValue contentType)
{
if (contentType.MediaType.Value == "application/json")
{
#if NET5_0_OR_GREATER
return System.Text.Json.JsonSerializer.Serialize(value,
new System.Text.Json.JsonSerializerOptions(System.Text.Json.JsonSerializerDefaults.Web));
#else
return System.Text.Json.JsonSerializer.Serialize(value);
#endif
}
throw new FormatterNotFoundException(contentType);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant