2

I have a controller to get all contacts where the last modified date is greater than or equal to the supplied date.

[HttpGet("LastModified/{lastModified:datetime}")]

This controller works if you submit a UTC date where the time zone is a negative (ie: Eastern Daylight Time is UTC-4). For example, this call successfully returns data (as expected):

/Contacts/LastModified/2020-04-06T08:00:00-04:00

The same controller fails with a "not found" response if the UTC date has a time zone in the positive (ie: Central European Summer Time is UTC+2). For example, this call fails:

/Contacts/LastModified/2020-04-06T08:00:00+02:00

Why does the + in the date cause a 404 not found? And what is the correct way to accept UTC dates?

(FYI: I even tried replacing the + in the URL with a %2B during testing, but it didn't work)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ThePeter
  • 883
  • 1
  • 7
  • 15
  • How can you tell when you are going to modify a file in the future? – jdweng Apr 10 '23 at 17:20
  • Could be https://stackoverflow.com/questions/26120919/plus-sign-in-web-api-routing ("IIS prevents plus-signs from being in URL path elements."), but you don't say if it is IIS or not (likely not as you have net.core, probably meaning .Net7) – Alexei Levenkov Apr 10 '23 at 17:23
  • @jdweng, It's not in the future. It's in 2020. The `+` is an offset from UTC. You know, time zones. So right now, it's ...T16:30:00-03:00, but it's also ...T21:30:00+02:00 – ikegami Apr 10 '23 at 19:31
  • The solution was to allow the + sign in the URL: https://stackoverflow.com/a/28228717/6587248 – ThePeter Apr 10 '23 at 20:31

0 Answers0