Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Issue: ODataEntityTypeSerializer closes connection when error happens to validate the data [464]

$
0
0
The issue happens when some data from server side missing some required property. The validation error is:

Microsoft.Data.OData.ODataException occurred
HResult=-2146233079
Message=The property 'Name[Nullable=False]' of type 'Edm.String' has a null value, which is not allowed.
Source=Microsoft.Data.OData
StackTrace:
at Microsoft.Data.OData.WriterValidationUtils.ValidateNullPropertyValue(IEdmProperty expectedProperty, ODataWriterBehavior writerBehavior, IEdmModel model)
InnerException:

Instead of sending back the error, server will close the connection.

The model to repro is:
public class Todo
{
public int ID { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Name1 { get; set; }
//[Required]
//public string Name2 { get; set; }
//[Required]
//public string Name3 { get; set; }
//[Required]
//public string Name4 { get; set; }
//[Required]
//public string Name5 { get; set; }
//[Required]
//public string Name6 { get; set; }
//[Required]
//public string Name7 { get; set; }
//[Required]
//public string Name8 { get; set; }

[Required]
public Person CreatedBy { get; set; }
public IEnumerable<Person> AssignedTo { get; set; }
}

public class Person
{
public int ID { get; set; }
[Required]
public string Name { get; set; }
}

The controller is:
public class TodoesController : ApiController
{
public IEnumerable<Todo> Get()
{
return new Todo[] {
new Todo {
ID = 0
},
new Todo {
ID = 1
}
};
}

Viewing all articles
Browse latest Browse all 7215

Trending Articles