question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Null value when posted in .NET Core

See original GitHub issue

Just 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:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
therealparmeshcommented, Jun 21, 2021

I’m thinking about adding a configuration option to allow for choosing between . and [] delimiters.

0reactions
therealparmeshcommented, Dec 21, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found