A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories.
Hello @Ibrahim Akuetiemhe and thank you for reaching out.
The behavior differs even between similar iPhone devices so I would suggest first determining whether the form values are already missing when ASP.NET Core parses the request, or whether they are present and only become null during model binding.
You can temporarily bypass the DTO with a diagnostic endpoint, for example:
[HttpPost("diagnose-upload")]
public async Task<IActionResult> DiagnoseUpload()
{
var request = Request;
if (!request.HasFormContentType)
{
return BadRequest(new
{
request.ContentType,
request.ContentLength
});
}
var form = await request.ReadFormAsync();
return Ok(new
{
request.ContentType,
request.ContentLength,
FormValues = form.ToDictionary(
item => item.Key,
item => item.Value.ToArray()),
Files = form.Files.Select(file => new
{
file.Name,
file.FileName,
file.ContentType,
file.Length
})
});
}
Compare the result from a working device with the affected iPhone
- Values are missing/incorrect in
Request.Form-> the issue is before model binding. Compare the requests from both devices, including the form data,Content-Type, multipart boundary, files, and payload. - Values are correct in
Request.Formbut null in[FromForm]-> the issue is likely with model binding or the DTO. CheckModelStatefor binding errors.
If possible, please provide the JavaScript submission code, DTO, controller action, and the diagnostic results from both a working and affected device. These should help identify where the values are being lost.
Hopefully, this should help narrow down the root cause. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation. Thank you.