asp.net-mvc – 在MVC SignalR服务器和Windows服务SIgnalR客户端之间的SignalR
发布时间:2020-05-23 09:28:16 所属栏目:asp.Net 来源:互联网
导读:我已经知道在这里,我可以在一个普通的 Windows服务中使用SignalR.我想在Windows Server作为SignalR Client和ASP.NET MVC SignalR Server之间进行通信.我用 this hubs guide,说 指定URL的服务器代码 app.MapSignalR(/signalr, new HubConfiguration()); 如果我
|
我已经知道在这里,我可以在一个普通的 Windows服务中使用SignalR.我想在Windows Server作为SignalR Client和ASP.NET MVC SignalR Server之间进行通信.我用 this hubs guide,说 指定URL的服务器代码 app.MapSignalR("/signalr",new HubConfiguration());
如果我这样做,邮件将在哪里?当您做新的HubConfiguration时,集线器是什么? 它说我可以连接 NET client code that specifies the URL
var hubConnection = new HubConnection("http://contoso.com/signalr",useDefaultUrl: false);
我会在我的Windows Server中,但是如果我在服务器上发送文本到http://myserver.com/signalr,我该如何得到它?什么中心? 还有哪里最好把它放在Windows服务中?一个很棒的例子 解决方法这解决了这个问题在客户端(Windows服务)上: protected override async void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
try
{
var hubConnection = new HubConnection("http://www.savitassa.com/signalr",useDefaultUrl: false);
IHubProxy alphaProxy = hubConnection.CreateHubProxy("AlphaHub");
await hubConnection.Start();
await alphaProxy.Invoke("Hello","Message from Service");
}
catch (Exception ex)
{
eventLog1.WriteEntry(ex.Message);
}
}
在服务器上: public class AlphaHub : Hub
{
public void Hello(string message)
{
// We got the string from the Windows Service
// using SignalR. Now need to send to the clients
Clients.All.addNewMessageToPage(message);
// Send message to Windows Service
} (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 我如何使用一个新的Phil的路由网络
- asp.net-mvc-3 – MVC将方法添加到jquery.validate.unobtru
- asp.net-core – ASP .NET Core 1.0 RTM本地化无法正常工作
- asp.net – CSRF验证令牌:会话ID安全吗?
- dropdownlist事件不显示在属性窗口asp.net Visual Studio 2
- asp.net – 在Response.Redirect()之后调用Response.End()
- Asp.net会话到期重定向到登录页面
- asp.net – Mysql中int(10)的最大大小是多少?
- asp.net – 使用Html而不是csHtml
- asp.net-mvc – 从控制器内部使用Html.ActionLink和Url.Act
推荐文章
站长推荐
热点阅读
