Please see http://go.microsoft.com/fwlink/?LinkId=272764 for more information on using SignalR.
Upgrading from 1.x to 2.0
-------------------------
Please see http://go.microsoft.com/fwlink/?LinkId=320578 for more information on how to
upgrade your SignalR 1.x application to 2.0.
Mapping the Hubs connection
----------------------------------------
SignalR Hubs will not work without a Hub route being configured. To register the default Hubs route, create a class called Startup
with the signature below and call app.MapSignalR() in your application's Configuration method. e.g.:
using Microsoft.AspNet.SignalR;
using Owin;
namespace MyWebApplication
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
Enabling cross-domain requests
---------------------------------------
To enable CORS requests, Install-Package Microsoft.Owin.Cors and change the startup class to look like the following:
using Microsoft.AspNet.SignalR;
using Microsoft.Owin.Cors;
using Owin;
namespace MyWebApplication
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.Map("/signalr", map =>
{
// Setup the cors middleware to run before SignalR.
// By default this will allow all origins. You can
// configure the set of origins and/or http verbs by
// providing a cors options with a different policy.
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
// You can enable JSONP by uncommenting line below.
// JSONP requests are insecure but some older browsers (and some
// versions of IE) require JSONP to work cross domain
// EnableJSONP = true
};
// Run the SignalR pipeline. We're not using MapSignalR
// since this branch is already runs under the "/signalr"
// path.
map.RunSignalR(hubConfiguration);
});
}
}
}
Starting the Web server
--------------------------------
To start the web server, call WebApp.Start<Startup>(endpoint). You should now be able to navigate to endpoint/signalr/hubs in your browser.
using System;
using Microsoft.Owin.Hosting;
namespace MyWebApplication
{
public class Program
{
static void Main(string[] args)
{
// This will *ONLY* bind to localhost, if you want to bind to all addresses
// use http://*:8080 or http://+:8080 to bind to all addresses.
// See http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
// for more information.
using (WebApp.Start<Startup>("http://localhost:8080/"))
{
Console.WriteLine("Server running at http://localhost:8080/");
Console.ReadLine();
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
SignalR-Server-JS-Client

共413个文件
dll:104个
xml:77个
nupkg:43个


温馨提示
SignalR-Server端+ SignalR-Web-Client+SignalR-控制台程序-Client, SignalR当所连接的客户端变得可用时服务器代码可以立即向其推送内容,而不是让服务器等待客户端请求新的数据
资源推荐
资源详情
资源评论


















收起资源包目录





































































































共 413 条
- 1
- 2
- 3
- 4
- 5
资源评论

- 胡桃先生2018-09-06报错,不能用

大熊程序猿
- 粉丝: 789
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- ctoc电子商务专题知识讲座.pptx
- C语言第7讲关系运算与逻辑运算if语句.ppt
- 基于单片机温度控制系统的设计.doc
- 基于AT89C52单片机的温室控制系统.doc
- 专题讲座资料(2021-2022年)单片机的红外防盗报警器.doc
- 购物网站策划书.doc
- 基于数据挖掘技术的负荷预测及主动设备维护可行性研究报告.doc
- 计算机教研组工作总结(2023年2023年第一学期).docx
- 【源版】第五章-数据库技术基础.ppt
- 工厂数字化网络监控系统解决方案.doc
- 网络谣言的传播与成因.ppt
- 基于GPS车辆跟踪系统的移动对象数据库应用研究.doc
- 光纤通信(第5版)课后习题答案要点.doc
- 高中数学第1章算法初步章末复习与总结课件新人教A版必修.ppt
- 网络研修学习总结.doc
- 中小型企业网站建设方案模板.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
