信号器无法在2012R2服务器上的IIS8中托管的WCF服务中工作 [英] Signalr not working in WCF service hosted in IIS8 on 2012R2 server

查看:76
本文介绍了信号器无法在2012R2服务器上的IIS8中托管的WCF服务中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是asp.net的新手,并且在过去的3天里尝试在我的C#WCF服务中配置一个简单版本的signalR。但我好像在四处走动。第一个问题是关于需要加载/创建不同元素或signalR的位置的混淆。也许最好让我理解所需的设置。

我的设置如下:



我的服务应用程序是一个在Windows 2012R2服务器上的IIS8中运行的C#WCF服务。 (服务

我的客户端应用程序是在同一个Windows 2012R2服务器上运行的C#WebForm应用程序(客户端

客户端应用程序有一个名为myJavaScript.js的JavaScript文件( JavaScript文件

用户通过运行CLIENT访问服务在网络浏览器上,通常是Chrome(浏览器



以下是我对 The服务客户&在我试图通过signalR从服务向浏览器发送简单消息时, JavaScript文件



更改为服务(应用程序名称DCRules2)

•从nuget Microsoft.AspNet下载。 SignalR v2.2.2

•从nuget下载Microsoft.AspNet.SignalR,Core v2.2.2

•从nuget下载Microsoft.AspNet.SignalRJS v2.2.2

•从nuget下载Microsoft.AspNet.SignalR.SystemWeb v2.2.2

•从nuget下载Microsoft.Owin.SystemWeb v3.1.0

•从nuget下载Microsoft.Owin v3.1.0

•从nuget下载Microsoft.Owin.Security v3.1.0

•从nuget Owin v1.0.0下载



添加了一个Owin启动类Startup1.cs



I am relatively new to asp.net and have spent the past 3 days trying to get a simple version of signalR configured in my C# WCF service. But I seem to be going around in circles. The first problem is confusion about where the different elements or signalR need to be loaded/created. Maybe it is best for me to give my understanding of the required setup.
My setup is as follows:

My Service application is a C# WCF service which runs in IIS8 on a windows 2012R2 server. ("The Service")
My Client application is a C# WebForm application running on the same windows 2012R2 server ("The Client")
The Client application has a JavaScript file called myJavaScript.js ("The JavaScript File")
Users access the service via the "CLIENT" running on a web browser, usually Chrome ("The Browser")

Below are the changes that I have made to "The Service", "The Client" & "The JavaScript file" in my attempts to send a simple message from the Service to the Browser via signalR.

Changes to "The Service" (application name DCRules2)
• Downloaded from nuget Microsoft.AspNet.SignalR v2.2.2
• Downloaded from nuget Microsoft.AspNet.SignalR,Core v2.2.2
• Downloaded from nuget Microsoft.AspNet.SignalRJS v2.2.2
• Downloaded from nuget Microsoft.AspNet.SignalR.SystemWeb v2.2.2
• Downloaded from nuget Microsoft.Owin.SystemWeb v3.1.0
• Downloaded from nuget Microsoft.Owin v3.1.0
• Downloaded from nuget Microsoft.Owin.Security v3.1.0
• Downloaded from nuget Owin v1.0.0

Added an Owin Startup Class Startup1.cs

using System;
using System.Threading.Tasks;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin;
using Owin;
using DCRules2;
[assembly: OwinStartup(typeof(DCRules2.Startup1))]

namespace DCRules2
{
    public class Startup1
    {
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
             //app.MapSignalR();
             //app.MapSignalR("/~/signalr", new HubConfiguration());          
             var hubConfiguration = new HubConfiguration();
             app.MapSignalR("/signalr", hubConfiguration);


      
        }
    }
}





添加了Hub类TiosHub.cs





Added Hub class TiosHub.cs

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;

namespace DCRules2
{
    //[HubName("tios")]
    public class TiosHub : Hub
    {
        // Tell all of the clients that there is an announcement
        public void Announce(string message)
        {
            Clients.All.Announce(message);
        }

    }
}





重建服务并重新启动IIS

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++



更改为客户端(应用程序名称DCRulesWeb01)

•从nuget下载Microsoft.AspNet.SignalR.Client v2.2.2

•从nuget下载Microsoft.Owin.SystemWeb v3.1.0

•从nuget下载Microsoft.Owin v3.1.0

•从nuget Owin v1.0.0下载



我添加了对Webform1.aspx的javascript引用





Rebuilt the service and restarted IIS
++++++++++++++++++++++++++++++++++++++++++++++++

Changes to "The Client" (application name DCRulesWeb01)
• Downloaded from nuget Microsoft.AspNet.SignalR.Client v2.2.2
• Downloaded from nuget Microsoft.Owin.SystemWeb v3.1.0
• Downloaded from nuget Microsoft.Owin v3.1.0
• Downloaded from nuget Owin v1.0.0

I added the javascript references to Webform1.aspx

<script src="~/Scripts/jquery.signalR-2.2.2.js">
</script> <script src="~/signalr/hubs"></script>





我添加了一个announce()方法Webform1.aspx.cs测试signalR





I added an announce() method to Webform1.aspx.cs to test signalR

// Test SignalR
        public void Announce(string message)
        {
            string msg = message;
        }





++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++名称DCRulesWeb01)



文件myJavaScript.js是一个客户端javascript文件,我将以下代码插入:



++++++++++++++++++++++++++++++++++++++++++++++++
Changes to "The JavaScript file" (application name DCRulesWeb01)

File myJavaScript.js is a clientside javascript file which I inserted the following code into:

// SignalR configuration
$(function () {
    var tioshub = $.connection.tiosHub;

    $.connection.hub.start().done(function () { });
   
    tioshub.client.announce = function (message) {
    console.info('Received message: ' +message);
    }

});





最后我重新构建了客户端应用程序并发布了项目并重新启动了IIS

当我运行服务并按F12时,我收到以下错误

1.无法加载资源 - 服务器响应状态为404(未找到)jquery.signalR-2.2 .2.js

2.无法加载资源 - 服务器响应了状态404(未找到)集线器

3.未捕获TypeError:无法读取属性'tiosHub'未定义



有一件事我期望看到是没有发生的文件夹信号器/集线器的创建。我假设这与上面的404错误有关。

有谁可以解释我可能做错了什么?



什么我试过了:



我花了几天研究这个,掉了很多兔子洞,但仍然没有答案



finally I re-built the Client application and published the Project and re-started IIS
When I run the service and press F12 , I get the following errors
1. Failed to Load resource - the server responded with a status of 404 (not found) jquery.signalR-2.2.2.js
2. Failed to Load resource - the server responded with a status of 404 (not found) hubs
3. Uncaught TypeError: Cannot read property 'tiosHub' of undefined

One thing I expected to see was the creation of a folder signalr/hubs which has not happened. I am assuming that this is related to 404 error above.
Can anyone explain what I might be doing wrong ?

What I have tried:

I have spent days researching this, gone down many rabbit holes but still do not have an answer

推荐答案

(function(){
var tioshub =
(function () { var tioshub =


.connection.tiosHub;
.connection.tiosHub;


。 connection.hub.start()。done(function(){});

tioshub.client.announce = function(message){
console.info('收到的消息:'+消息);
}

});
.connection.hub.start().done(function () { }); tioshub.client.announce = function (message) { console.info('Received message: ' +message); } });





最后我重新构建了客户端应用程序并发布了项目并重新启动了IIS

当我运行该服务并按F12时,我收到以下错误

1.无法加载资源 - 服务器响应状态为404(未找到)jquery.signalR-2.2.2.js

2.无法加载资源ce - 服务器响应状态为404(未找到)集线器

3.未捕获TypeError:无法读取属性'tiosHub'未定义



我希望看到的一件事是创建一个尚未发生的文件夹信号器/集线器。我假设这与上面的404错误有关。

有谁可以解释我可能做错了什么?



什么我试过了:



我花了几天时间研究这个问题,遗失了许多兔子洞但仍然没有答案



finally I re-built the Client application and published the Project and re-started IIS
When I run the service and press F12 , I get the following errors
1. Failed to Load resource - the server responded with a status of 404 (not found) jquery.signalR-2.2.2.js
2. Failed to Load resource - the server responded with a status of 404 (not found) hubs
3. Uncaught TypeError: Cannot read property 'tiosHub' of undefined

One thing I expected to see was the creation of a folder signalr/hubs which has not happened. I am assuming that this is related to 404 error above.
Can anyone explain what I might be doing wrong ?

What I have tried:

I have spent days researching this, gone down many rabbit holes but still do not have an answer

这篇关于信号器无法在2012R2服务器上的IIS8中托管的WCF服务中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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