RawRequestBodyFormatter Class

Formatter that allows content of type text/plain and application/octet stream or no content type to be parsed to raw data. Allows for a single input parameter in the form of:

public string RawString([FromBody] string data) (text/plain) public byte[] RawData([FromBody] byte[] data) (application/octet-stream)

Add to MVC processing with:

services.AddMvc(o ⇒ o.InputFormatters.Insert(0, new RawRequestBodyFormatter()));

More info: https://weblog.west-wind.com/posts/2017/Sep/14/Accepting-Raw-Request-Body-Content-in-ASPNET-Core-API-Controllers

Westwind.AspNetCore.Formatters.RawRequestBodyFormatter

Class Members

MemberDescription
Constructor
CanRead Allow text/plain, application/octet-stream and no content type tobe processed
public bool CanRead(InputFormatterContext context)
ReadRequestBodyAsync Handle text/plain or no content type for string resultsHandle application/octet-stream for byte[] results
public Task ReadRequestBodyAsync(InputFormatterContext context)
Namespace: Westwind.AspNetCore.Formatters

Assembly: Westwind.AspNetCore.dll



© West Wind Technologies, 2025 • Updated: 2025-03-08
Comment or report problem with topic