Attached a repro.
__Issue__:
The below action is returning null when actually there is valid data in the content. The issue here is that the content header ‘Content-Length’ value is 0 even though the underlying stream length is actually greater than 0…since the content-length is 0, the deserialization thinks that there is no content to be deserialized and hence returns default value for the C# type(DataPack here) which is null.
```
[HttpPost("MultipartPost")]
public async Task<DataPack> MultipartPost()
{
MultipartMemoryStreamProvider provider = await Request.Content.ReadAsMultipartAsync();
HttpContent content = provider.Contents[0];
return await content.ReadAsAsync<DataPack>();
}
```
__Workaround__:
```
[HttpPost("MultipartPost")]
public async Task<DataPack> MultipartPost()
{
MultipartMemoryStreamProvider provider = await Request.Content.ReadAsMultipartAsync();
HttpContent content = provider.Contents[0];
// workaround
Stream stream = await content.ReadAsStreamAsync();
content.Headers.ContentLength = stream.Length;
return await content.ReadAsAsync<DataPack>();
}
```
__Issue__:
The below action is returning null when actually there is valid data in the content. The issue here is that the content header ‘Content-Length’ value is 0 even though the underlying stream length is actually greater than 0…since the content-length is 0, the deserialization thinks that there is no content to be deserialized and hence returns default value for the C# type(DataPack here) which is null.
```
[HttpPost("MultipartPost")]
public async Task<DataPack> MultipartPost()
{
MultipartMemoryStreamProvider provider = await Request.Content.ReadAsMultipartAsync();
HttpContent content = provider.Contents[0];
return await content.ReadAsAsync<DataPack>();
}
```
__Workaround__:
```
[HttpPost("MultipartPost")]
public async Task<DataPack> MultipartPost()
{
MultipartMemoryStreamProvider provider = await Request.Content.ReadAsMultipartAsync();
HttpContent content = provider.Contents[0];
// workaround
Stream stream = await content.ReadAsStreamAsync();
content.Headers.ContentLength = stream.Length;
return await content.ReadAsAsync<DataPack>();
}
```