Open mhamri opened 5 years ago
I'm not sure I follow your description.
What is your expected result?
Do you think that you should have, after deserialization, a date with a timezone for Singapore?
But you're sending a value with a specific Timezone UTC (Z) and you're deserializing a DateTimeOffset
which honors this timezone. The offset is not truncated, it specified via 'Z' to be UTC. If you don't like that you can either send the correct Timezone or change your model to use DateTime
and change the knobs to do local TimeZone Handling (as you've already tried). But as https://www.newtonsoft.com/json/help/html/DatesInJSON.htm specified, those knobs don't work with DateTimeOffset
.
yes, you are right, it was a bug in my side, thanks for explanaing.
coming from here
Describe the bug
i have a model like this
and an action like this
and i'm sending request from angular as a json
which contains a valid date
but what i'm getting in the api is wrong
if i inspet the variable in the immediate windows i can see that the offset couldnt' parse correctly
i tried to change the mvc options to
i also played with these options
and
which didn't help, i dont' think it's about deserialize options.
our staging server is using linux and we don't have this problem, but our production use IIS on windows server and have this problem. i am not sure if it's related on the OS. but if i try it on my local development(which is windows 10) aslo i'm facing the same bug.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
something like this shouldn't need to have custom modelbinder or custom serilizer implementation. i checked a lot of solutions in SO, but most ask to create a new serilizer or modelBinder which doesn't make sense. when the input is valid and model ask for datetimeoffset why the offset is truncated?
Additional context
Include the output of
dotnet --info