```
public class CustomersController : ApiController
{
public Customer GetCustomer(int key)
{
return null;
}
}
```
Use the url http://localhost/MyTypes/2886753098675309
This should fail to parse as 2886753098675309 is too big for an int.
Expectation: The controller action gets invoked, with model state errors - or at least a better error message that contains the model state errors.
Result:
```
{
"Message": "The request is invalid.",
"MessageDetail": "The parameters dictionary contains a null entry for parameter 'key' of non-nullable type 'System.Int32' for method 'RuntimeTests.Customer GetCustomer(Int32)' in 'RuntimeTests.CustomersController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter."
}
```
See http://aspnetwebstack.codeplex.com/workitem/936 for how this makes OData scenarios harder.
Comments: Because the "key" parameter is a regular int, it is a ValueType, which means that it must have a valid value in order to be called. To get the action to be called you can use a nullable int ("int?") and then the action should be dispatched and ModelState will contain the error.
public class CustomersController : ApiController
{
public Customer GetCustomer(int key)
{
return null;
}
}
```
Use the url http://localhost/MyTypes/2886753098675309
This should fail to parse as 2886753098675309 is too big for an int.
Expectation: The controller action gets invoked, with model state errors - or at least a better error message that contains the model state errors.
Result:
```
{
"Message": "The request is invalid.",
"MessageDetail": "The parameters dictionary contains a null entry for parameter 'key' of non-nullable type 'System.Int32' for method 'RuntimeTests.Customer GetCustomer(Int32)' in 'RuntimeTests.CustomersController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter."
}
```
See http://aspnetwebstack.codeplex.com/workitem/936 for how this makes OData scenarios harder.
Comments: Because the "key" parameter is a regular int, it is a ValueType, which means that it must have a valid value in order to be called. To get the action to be called you can use a nullable int ("int?") and then the action should be dispatched and ModelState will contain the error.