【发布时间】:2013-07-24 04:06:04
【问题描述】:
我在我的一个应用程序中遇到了这个问题,我已将其剥离并设置了一个小型测试环境,但问题仍然存在。
我正在发布以下对象 (JSON)
{
"eventName":"Testing from Services",
"tickets":10,
"_date":"10/10/2013",
"_time":"8:00 PM",
"ticketsLocation":"Testing from Services",
"date":"2013-10-11T00:00:00.000Z"
}
使用以下 ajax 调用
self.save = function (item, url, success) {
$.ajax({
type: "post",
data: JSON.stringify(item),
contentType: "application/json, charset=utf-8",
traditional: true,
datatype: "json",
url: self.domain + url,
success: success,
error: self.error
});
};
然后在服务器上用如下代码绑定数据
var Model = this.Bind<PropertyType>();
其中PropertyType 是正确的类型 (Event)。
这里是Event类供参考
public class Event
{
public string EventName { get; set; }
public int Tickets { get; set; }
public Venue Venue { get; set; }
public string TicketsLocation { get; set; }
public DateTime Date { get; set; }
public List<EventRequest> Requests { get; set; }
}
这在 Firefox 中运行良好。在 Chrome 和 IE 中,Model 最终成为具有所有空值的 Event 对象。据我所知(通过使用 Fiddler),所有浏览器之间的发布请求完全相同。我还在其他机器上对此进行了测试,排除了我的机器和/或浏览器的问题。
有什么想法吗?我不明白浏览器如何影响 Nancy 模型绑定...
【问题讨论】:
标签: c# javascript ajax nancy