Skip to content

Instantly share code, notes, and snippets.

View toothache's full-sized avatar
🤷‍♂️
┑( ̄Д  ̄)┍

Yateng Hong toothache

🤷‍♂️
┑( ̄Д  ̄)┍
View GitHub Profile
@toothache
toothache / OptionalBodyBindingJsonInputFormatter.cs
Created January 24, 2021 05:30
ASPNetCore custom input formmater to work around the optional [FromBody] model binding issue.
using System;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Formatters;
namespace MyFormatters
{
public class OptionalBodyBindingJsonInputFormatter : TextInputFormatter
{
private SystemTextJsonInputFormatter jsonFormatter;