-
Notifications
You must be signed in to change notification settings - Fork 3
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
Labels
Comments
I will take a look at this. |
Reference variabels should be null. Unsure about value types, default or error. What does MVC do by default?
… On 26 Aug 2017, at 00:02, yentheo ***@***.***> wrote:
I will take a look at this.
Any preference?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
At the moment, if the model binder isn't able to bind everything, he binds nothing. 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 |
Try to omit it completely so {}
… On 26 Aug 2017, at 13:36, yentheo ***@***.***> wrote:
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.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When null is submitted for a non nullable field you get a null reference exception, no further info is available on what is wrong.
The text was updated successfully, but these errors were encountered: