【发布时间】:2013-06-21 20:19:58
【问题描述】:
我收到以下消息:
[Route("/devices/{DeviceId}/punches/{EmployeeId}/{DateTime}", "GET,POST")]
public class Punch
{
public string DeviceId { get; set; }
public string EmployeeId { get; set; }
public DateTimeOffset DateTime { get; set; }
public string TimeZoneId { get; set; }
public PunchKind Kind { get; set; }
}
我需要在 DateTime 部分传递一个完整的DateTimeOffset...
以下工作完美:
http://localhost:54146/devices/1001/punches/666/2012-04-01
但是当我尝试传递完整的日期时间偏移数据时,它失败并出现 HTTP 400 错误:错误请求。到目前为止,我已经尝试了以下相同的错误(即使是 URL 编码也没有帮助):
http://localhost:54146/devices/1001/punches/666/2012-04-01T20:59:00.0000000-03:00
http://localhost:54146/devices/1001/punches/666/2012-04-01 20:59:00.0000000-03:00
http://localhost:54146/devices/1001/punches/666/2012-04-0120:59:00.0000000-03:00
http://localhost:54146/devices/1001/punches/666/2012-04-01T20%3A59%3A00.0000000-03%3A00
并且其他排列都失败并出现相同的错误。
如何将 DateTimeOffset 作为 URL 的一部分传递?
【问题讨论】:
-
尝试对日期时间部分进行编码。例如
2012-04-01T20%3A59%3A00.0000000-03%3A00 -
我已经这样做了...我将更新问题以表明我已经尝试过了...
标签: asp.net servicestack