Recently upgrade one application from .NET Core 3.1 to .NET 5. For some reason the DateTimeKind was Local in 3.1 and now it is UTC in .NET 5.
I created a simple project showing this problem,
https://github.com/ShehulCS/Dotnet5DateTimeIssue
Question,
The issue you're describing is related to a bug fix.
In short, the Z
at the end of an ISO 8601 timestamp explicitly means UTC. The bug was that when such a value is obtained through model binding, it was previously being interpreted as DateTimeKind.Local
instead of DateTimeKind.Utc
. That bug has been corrected in 5.0.
The bug is described in this issue: https://github.com/dotnet/aspnetcore/issues/11584
It was fixed in this PR: https://github.com/dotnet/aspnetcore/pull/24893
A request to backport the fix to 3.1 was made (but denied) here: https://github.com/dotnet/aspnetcore/issues/27618
The new behavior is correct. If you were relying on the old behavior, you probably have other .NET code that needs to be corrected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.