Optional<T> with [FromBody] #270
Unanswered
sps-campbellwray
asked this question in
Q&A
Replies: 2 comments 7 replies
-
Do you have standalone example of this exception? It was fixed by marking |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @sakno, I'm not sure I totally understand what you are asking. I was using this on an API controller, so something like:
When POSTing the example body I provided in my original question I was getting a |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I just found this issue discussing the limitations of .NET Model Binders and
Optional<T>
#213 when using query string parameters.I am running into the same issue with
[FromBody]
when trying to convert the JSON body of a request into an object with a series ofOptional<T>
properties.When providing the following test value:
I get the same
System.ArgumentException: The type 'System.String&' may not be used as a type argument.
exception.Is there any way to make this work? It seems crazy that I can do this
with two lines of code, but as soon as there is a ModelBinder in the way everything breaks.
Beta Was this translation helpful? Give feedback.
All reactions