如何设置 C# winforms 应用程序来托管 SignalR 集线器? [英] how to setup a C# winforms application to host SignalR Hubs?

查看:33
本文介绍了如何设置 C# winforms 应用程序来托管 SignalR 集线器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通读了 SignalR 文档并观看了一些视频,但是我无法让 SignalR 在 winforms 应用程序中托管.

I have read through the SignalR docs and watched a few of the videos, however I can not get SignalR to host within a winforms application.

我尝试使用 SignalR wiki 上的源代码:https://github.com/SignalR/SignalR/wiki/Self-host

I have tried using source code off the SignalR wiki: https://github.com/SignalR/SignalR/wiki/Self-host

如果您查看完整示例 - 集线器",服务器"变量是什么?我不明白这是如何工作的或如何将其转换为 C#.根据维基默认的 SelfHost 实现是基于 HttpListener 构建的,可以托管在任何类型的应用程序(控制台、Windows 服务等)中."

If you look at the "Full Sample - Hubs", what is the "server" variable? I do not understand how this works or how to convert it to C#. According to the wiki "The default SelfHost implementation is built on HttpListener and can be hosted in any kind of application (Console, Windows Service etc). "

我想在 C# 中托管 SignalR 并在 asp.net 中使用它.任何人都可以帮我解释一下吗?

I would like to host SignalR in C# and consume it in asp.net. Could anyone please shed some light on this for me?

推荐答案

为了使其适用于 C# 和 ASP.NET,我不得不使用跨域".

In order to make this to work for C# and ASP.NET I had to use "Cross Domain".

在我使用的 JavaScript 中:

In the JavaScript I used:

<script type="text/javascript" src='http://localhost:8081/signalr/hubs'></script>

并添加:

$.connection.hub.url = 'http://localhost:8081/signalr'

这篇关于如何设置 C# winforms 应用程序来托管 SignalR 集线器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆