我想使用 Signalr 将对象从 Javascript 发送到服务器,但未调用服务器端方法。
// Model-Class generated by EF5.0
public partial class ttFragen
{
...
public long ID { get; set; }
public Nullable<long> UserID { get; set; }
public string Titel { get; set; }
public string Text { get; set; }
public Nullable<int> ProductID { get; set; }
public Nullable<int> Score { get; set; }
public Nullable<System.DateTime> Date { get; set; }
}
public class Chat : Hub
{
public void Send2(ttFragen frage)
{
...
}
}
客户代码:
$.connection.hub.start().done(function() {
$("#broadcast").click(function () {
var frage = {
ID: -1,
UserID: -1,
Titel: "titel2",
Text:"testsst",
ProductID: -1,
Score: -1,
Date : null
};
chat.server.Send2(frage); // nothing happens
});