NancyFx / Nancy

Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono
http://nancyfx.org
MIT License
7.16k stars 1.47k forks source link

datetime deserialization problem #2967

Closed tasoss closed 5 years ago

tasoss commented 5 years ago

Hello. I'm trying to convert a project of mine to .net core / .net standard. I try to pass a DateTime object to a call and i get

FormatException: String '/Date(1560807247117+0300)/' was not recognized as a valid DateTime.

I'm using the latest version of nancy(github). I'm also using Kestrel as a web server,visual studio 2017, .net standard 2 , .net core 2.2

The code looks like

 Post("/schedule/timezoned/period/dto/async", async (x, ct) =>
            {
                var reqdto = this.Bind<TimeZonedGamesDTO>();

public class TimeZonedGamesDTO
    {
        public DateTime From { get; set; }
        public DateTime To { get; set; }
        public string TimeZoneId { get; set; }
        public int AdditionalDays { get; set; }

    }

var reqdto = new TimeZonedGamesDTO { From = DateTime.Now, To = DateTime.Now, TimeZoneId = timeZoneId };

var res1 = await Client.PostAsync<TimeZonedGamesDTO>($"/schedule/timezoned/period/dto/async",reqdto);

Thank you!

tasoss commented 5 years ago

It had nothing to do with nancy but with the client i was using to connect to the services. Sorry.