Skip to content

ASP.NET Core model binder deserilises UTC time string to local time rather than UTC time #11584

@ZeanQin

Description

@ZeanQin

Describe the bug

When a user passes a UTC time string as query parameter of a GET request, the model binder converts it to a "Local" kind DateTime object rather than a UTC DateTime object. And the user has to call DateTime.ToUniversalTime() to convert it to utc time, or write custom model binder to change the behaviour globally.

To Reproduce

Steps to reproduce the behavior:

  1. Send a GET request to an endpoint with a UTC time string such as https://<something>.com/{action}/{id}?time=2019-06-14T02:30:04.0576719Z
  2. The time parameter in the corresponding controller is a local time

Expected behavior

The retrieved time should be a utc time.

Metadata

Metadata

Assignees

Labels

DoneThis issue has been fixedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.feature-model-binding

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions