AspNetCoreUnsupportedMediaType

AspNetCoreUnsupportedMediaType is an ASP.NET Core solution which requires all http POST and PUT requests to have the 'Content-Type' header set to 'application/json'.


Keywords
UnsupportedMediaType, 415
License
MIT
Install
Install-Package AspNetCoreUnsupportedMediaType -Version 1.0.1

Documentation

AspNetCoreUnsupportedMediaType

The AspNetCoreUnsupportedMediaType package is an ASP.NET Core solution which requires all http requests to have the 'Content-Type' header set to 'application/json'.

NuGet

NuGet install:

Install-Package AspNetCoreUnsupportedMediaType

Startup.cs code:

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc()
            .AddMvcOptions(options =>
            {
                options.Filters.Add(typeof(UnsupportedMediaTypeResultFilter));
                options.Filters.Add(typeof(ValidateUnsupportedMediaTypeFilterAttribute));
            });
}