我有一个 ASP.NET MVC API 站点,其中我的一个模型需要 DateTime,但无论我做什么,它都不会接受我作为有效模型发送的数据!
我试过了
{"Owner":"s083151","Permissions":"public","Name":"SomeRandomMeeting","Begin":"2013-03-28T13:00:00.2124557+01:00","End":"2013-03-28T17:00:00.2124557+01:00","Url":"MyRandomUrl"}
和
{"Owner":"s083151","Permissions":"public","Name":"SomeRandomMeeting","Begin":Date(1364234400),"End":Date(1364248800),"Url":"MyRandomUrl"}
和
{"Owner":"s083151","Permissions":"public","Name":"SomeRandomMeeting","Begin":1364234400,"End":1364248800,"Url":"MyRandomUrl"}
和
{"Owner":"s083151","Permissions":"public","Name":"SomeRandomMeeting","Begin":"1364234400","End":"1364248800","Url":"MyRandomUrl"}
但没有一个被接受为 Model.IsValid,我做错了什么?
我使用提琴手来测试这里的请求是我的请求标头
User-Agent: Fiddler
Content-Type: application/json
数据模型
[DataContract]
public class MeetingModel
{
[Required]
[StringLength(500)]
public string Owner { get; set; }
[Required]
public string Permissions { get; set; }
[Required]
[StringLength(500)]
public string Name { get; set; }
[Required]
public DateTime Begin { get; set; }
[Required]
public DateTime End { get; set; }
[Required]
[StringLength(75)]
public string Url { get; set; }
public string MeetingId { get; set; }
public TimeSpan Duration { get; set; }
public List<UserModel> Hosts { get; set; }
public List<UserModel> Participants { get; set; }
}