AsyncEntitySetController BUG - does not properly interpret JSON content

Topics: ASP.NET Web API
Sep 11, 2013 at 10:27 PM
Edited Sep 13, 2013 at 4:14 PM

AsyncEntitySetController does not properly interpret JSON content.

Please fix it for EntitySetController, ODataController and ApiController as well.

This works (Controller called with proper entity value) Unfortunatly this is hand edited
"Id":"0","GenreId":"5","ArtistId":"5","Title":"555","Price":"5.99","AlbumArtUrl":"","RowVersion":"AAAAAAAAqqo=","Artist":null,"Genre":null}

This dos not work (Controller called with null entity value) Fortunately created by HttpClient.PutAsJsonAsync() :-)
"Id":0,"GenreId":5,"ArtistId":5,"Title":"555","Price":5.99,"AlbumArtUrl":"","RowVersion":"AAAAAAAAqqo=","Artist":null,"Genre":null,"Carts":[]}

Problem
  • "Id":0
  • "ArtistId":5
  • "Price":5.99
  • "Carts":[]
The controller is getting called in BOTH cases.
There are NO exceptions!
Developer
Sep 11, 2013 at 10:35 PM
Can you add the following piece of code to your application and apply the 'ValidationFilter' attribute on your controller that is getting called and let us know what response information you are seeing? Also set config.IncludeErrorDetailPolicy to Always to enable getting the full error detail (if any) in the response.
public class ValidationFilterAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            if(!actionContext.ModelState.IsValid)
            {
                actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest, actionContext.ModelState);
            }
        }
    }
Sep 11, 2013 at 10:47 PM
Edited Sep 13, 2013 at 4:13 PM
See comprehensive answer below from danroth27.
Thank you Daniel.
Sep 11, 2013 at 10:51 PM
Edited Sep 13, 2013 at 4:14 PM
See comprehensive answer below from danroth27.
Thank you Daniel.
Sep 11, 2013 at 10:54 PM
Edited Sep 13, 2013 at 4:13 PM
See comprehensive answer below from danroth27.
Thank you Daniel.
Coordinator
Sep 13, 2013 at 3:53 PM
Please see my response on the other thread you started: https://aspnetwebstack.codeplex.com/discussions/456461.

Daniel Roth