user6251216 user6251216 - 1 month ago 11x
ASP.NET (C#) Question

ASP .NET Web API - Get plain json in POST method

I have a Web API controller that has a POST method which receives data from the request body, and all it does is send it to another web service, so deserializing the data is not necessary. How can I disable the auto deserialization done by the Web API?

public IHttpActionResult Post([FromBody]string data)
//Post with http client...


The data arrives as null with this signature.


Check this:

public async Task<HttpResponseMessage> Post(HttpRequestMessage request)
    var data = await request.Content.ReadAsStringAsync();
    // do stuff with the content

More about the solution: