Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modelbinder errors not transparent #1

Open
BennyM opened this issue Jul 10, 2017 · 4 comments
Open

Modelbinder errors not transparent #1

BennyM opened this issue Jul 10, 2017 · 4 comments
Assignees

Comments

@BennyM
Copy link
Member

BennyM commented Jul 10, 2017

When null is submitted for a non nullable field you get a null reference exception, no further info is available on what is wrong.

yentheo added a commit that referenced this issue Aug 25, 2017
@yentheo yentheo self-assigned this Aug 25, 2017
@yentheo
Copy link
Contributor

yentheo commented Aug 25, 2017

I will take a look at this.
Any preference?

@BennyM
Copy link
Member Author

BennyM commented Aug 26, 2017 via email

@yentheo
Copy link
Contributor

yentheo commented Aug 26, 2017

At the moment, if the model binder isn't able to bind everything, he binds nothing.
For example:

public class Request
{
    public string StringValue { get; set; }
    public int IntValue { get; set; }
}

[Route("api/test")]
public void Post([FromBody]Request req)
{
    ...
}

So let's say we post something like this body
{ "stringValue": "value", "intValue": 5 }
The req variable will correctly initialised.
If we post something like { "stringValue": "value", "intValue": null }
The req variable will be null. No warning, no nothing.

@BennyM
Copy link
Member Author

BennyM commented Aug 26, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants