I have a web interface API with a POST method as follows.
public class MyController : ApiController
{
public HttpResponseMessage Post([FromBody]MyClass request)
{
return Request.CreateResponse(HttpStatusCode.OK, someResponseObject);
}
....
}
It is consumed by HTTPClient as follows
HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.BaseAddress = new Uri("http://localhost");
MyClass requestClient = new MyClass();
var task = httpClient.PostAsJsonAsync("api/my", requestClient)
It works fine when the size of the MyObject passed in the controller's POST method parameter is small in size. However, in the case when the size of this object is large, I get zero for the request object in the parameters of the POST method. In one case, the size of the requestClient object passed from the request on the client side is ~ 5 MB, and in the POST method I get the request object as null. Note that the web API is hosted in IIS. Is there any parameter that I need to change for a valid size.
UPDATE:
web.config POST.
httpRuntime maxRequestLength = "2147483647" /" >
requestClient ~ 50 . POST . , PostAsJsonAsyn, System.Net.HttpRequestException .
: 404 ( ).
maxRequestLength .