62,046
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Owin;
using Owin;
using Microsoft.Owin.Cors;
using LeaRun.WebApp;
[assembly: OwinStartupAttribute(typeof(Startup))]
namespace LeaRun.WebApp
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
//app.MapSignalR<MyConnection1>("/myconnection");
app.Map("/myconnection",
map =>
{
map.UseCors(CorsOptions.AllowAll);
map.RunSignalR<MyConnection1>();
}
);
}
}
}
var conn = $.connection("http://***.***.*.**:****/myconnection");
conn.start().done({ jsonp: true });
function aaa() {
conn.start().done(function (data) {
var msg = "123";
conn.send(msg);//发送给服务器
});
};
app.Map("/echo", map =>
{
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
EnableJSONP = true,//跨域的关键语句
EnableJavaScriptProxies = false,
EnableDetailedErrors = true
};
map.RunSignalR(hubConfiguration);
});
app.MapSignalR();