Null value when posted in .NET Core
See original GitHub issueJust to mention in case someone runs into this.
When posting a file in a nested object to a controller, it is always null, it just happens with types of IFormFile, seems like the issue is the key in the formdata.
Instead of setting the key to obj[nested]
it should go like obj.nested
. I changed the key const to const key = pre ? pre + "." + prop : prop;
and it worked fine. Like I said, all the other props worked fine, just the files are the one who always post null.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:5 (3 by maintainers)
Top Results From Across the Web
POST null because property type does not match?
In the class I defined it as bool , but JSON defined it as null . When I either change the value to...
Read more >Omit null value properties in ASP.NET Core OData
NET Core OData serializes a single value property as “null”, and a collection value property as an empty array if its value is...
Read more >ASP.NET Core Pitfalls – Null Models in Post Requests
Sometimes, when AJAX posting to a controller, you may get a null model. Why?Let's exclude the obvious – you didn't send a null...
Read more >Request model null in .NET core API if input json value ...
This is due to .NET Core using the new System.Text.Json library instead of the Newtonsoft.Json library. ... However, passing a telephone "number" ...
Read more >(ASP.NET Core) Model foreign key returns null value!
Hi,. I'm having an issue with my models, where whenever i try to get a value using the FK, I get a error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m thinking about adding a configuration option to allow for choosing between
.
and[]
delimiters.I’ve added a new configuration option called
dotsForObjectNotation
in v4.3.0 that should help solve most of the cases brought up here. I think we should create new issues for new cases.