asp.net mvc - Converting date format to -


hi guys/girls im super new asp.net mvc , im trying convert date readable format. looks this.

/date(1444892163827)/ 

my model

public class movie     {         internal string title;         internal datetime releasedate;         internal string genre;          public int id { get; set; }          [required]         public string title { get; set; }          public datetime releasedate { get; set; }          [required]         public string genre { get; set; }     }      public class moviedbcontext : dbcontext     {         public dbset<movie> movies { get; set; }     } 

my controller

public jsonresult getall()         {             using (moviedbcontext datacontext = new moviedbcontext())             {                 var movielist = datacontext.movies.tolist();                 return json(movielist, jsonrequestbehavior.allowget);             }         }          public jsonresult getmoviebyno(string movno)         {             using (moviedbcontext datacontext = new moviedbcontext())             {                 int no = convert.toint32(movno);                 var movielist = datacontext.movies.find(no);                 return json(movielist, jsonrequestbehavior.allowget);             }          }       

any appreciated !

you need create customjsonresult in mvc use example json.net isodatetimeconverter or should change project mvc webapi if return json.

create class https://stackoverflow.com/a/9302054/4599089 (approach 2) , use in controller:

    public jsonresult getall()     {         using (moviedbcontext datacontext = new moviedbcontext())         {             var movielist = datacontext.movies.tolist();             return new customjsonresult(){data = movielist};         }     }      public jsonresult getmoviebyno(string movno)     {         using (moviedbcontext datacontext = new moviedbcontext())         {             int no = convert.toint32(movno);             var movielist = datacontext.movies.find(no);             return new customjsonresult(){data = movielist};         }      }   

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -