c# - Web API can't deserialize a Javascript Date.toISOString()? -


i'm looking way pass javascript dates .net web api controllers without installing library on client...

i'm expecting javascript dates deserialize .net datetime.

var date = new date();  post({currentdate: date.toisostring()});  

arrives @ server datetime.min (indicating failed deserialize).

here's example of being sent on wire, apicontroller not able create datetime correct date...

request:

{"date":"2014-04-16t17:03:03.383z"} 

c#:

    [serializable]     public class myobj      {          public datetime date { get; set; }     }      public class mycontroller : apicontroller     {         public httpresponsemessage post(myobj dd)         {             // dd's date property equals datetime.min rather correct date...             return null;         }      } } 

remove [serializable] attribute.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -