Wednesday, 15 July 2015

asp.net mvc - Passing null value as nullable decimal property to controller action -



asp.net mvc - Passing null value as nullable decimal property to controller action -

i'm trying pass null value in json object let's say: { 'property': null } controller action in asp.net mvc in action method see property gets 0 value instead of null.

what can this?

just dont send property or delete in client-side : delete x.yourproperty

for illustration if have .net mvc controller nullable property this:

public jsonresult someaction(decimal? yourproperty){ //your code goes here }

if in client-side phone call ajax request yourproperty: null model binder set 0, int or string set emptystring

so if want send null avoid sending it, or if it's property have set before need delete property: delete x.yourproperty

asp.net-mvc json asp.net-mvc-4

No comments:

Post a Comment