SignalR 传Model类型的参数

集线器方法

集线器写了一个方法是这样的

   public void test(string name, Customer customer)

第一个参数是string类型的,第二个参数,是一个Model类型的,怎么传?

js调用

chat.server.guestConnect($('#name').val(),  {
                    Contact:"@customer.Contact",
                    LastVisitIP:"@customer.LastVisitIP",
                    Company:"@customer.Company",
                    Email:"@customer.Email",
                    Country:"@customer.Country",
                    Tel:"@customer.Tel"
    });

就是这样,如果你不这样写,传到后台的就是一个字符串,想传Model类型的参数,必须这样写,Model的字段不必写完,写需要的几个就可以了

原文地址:https://www.cnblogs.com/yunquan/p/11045369.html