/signalr/hubs not being generated when upgrading t

2019-02-09 18:18发布

问题:

I have a working chat like application running on SignalR 1.1.2 that will be put onto load balanced servers, so I need to implement a backplane solution to sync up the servers.

This is an ASP.NET MVC4 .NET 4.5 application. Using SignalR Hubs, and not Persistent Connection. The app utilizes AngularJS on the client side to handle the ui bindings and updates.

I've followed the steps listed out here to implement the sql server backplane and used the steps outlined in the 1.x to 2.0 migration outlined out here. The solution builds, but when hitting the page that utilizes SignalR the "/signalr/hubs" script reference returns a 500 error.

Here's a list of steps I took so far.

  • Using nuget, removed all references and dependencies related to SignalR 1.1.2. Double checked /bin and /packages directories to make sure they no longer reference any old libraries. This is per comment found on the github issue relating to a 2.0 upgrade that said uninstalling and reinstalling SignalR was the way to go for an upgrade.

  • Installed SignalR 2.0.0-beta2 via Package Manager Console (PMC) Install-Package Microsoft.AspNet.SignalR -Pre

  • Installed SQL Server Messaging Backplane using PMC Install-Package Microsoft.AspNet.SignalR.SqlServer -Pre

  • Removed RouteTable.Routes.MapHubs(); from Global.asax

  • Created Startup class in root of project.

Startup.cs

using Microsoft.AspNet.SignalR;
using Microsoft.Owin;
using Owin;

namespace My.NameSpace
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapHubs();
        }
    }
}
  • Added <add key="owin:AppStartup" value="My.NameSpace.Startup, App_Code"/> to <appSettings> inside Web.config

  • Put a breakpoint in the Startup.Configuration() method and verified that it was getting hit and executing app.MapHubs without exceptions when the app started

  • I'm not using Persistent Connection, so did not include the line app.MapConnection<MyConnection>("/echo"); and am not getting any ambiguous definition issues.

  • The chat app page references the following libs

    • jquery-1.8.3.js
    • jquery.signalR-2.0.0-beta2.js
    • <script src='/signalr/hubs'></script>
    • AngularJS v1.1.5
  • When the project runs, /signalr/hubs is not found by the chat app page

  • chrome dev tools returns 500 Internal Server Error for the /signalr/hubs call on the network tab.

  • the file system does not have a /signalr/hubs directory

My next step is to see if I can create a new solution with a very basic hub and see if I can get Signal 2.0 working. If it does I'll compare the two solutions to see what the differences are.

Does anyone have an idea of what else I could check or research to get this working?

Related StackOverflow questions with a similar issue: one, two

回答1:

Turns out the issue was fixed by changing the project config to use Local IIS Web server instead of Visual Studio Developer Server (Cassini).

Found the cause by going to /signalr/hubs url in my browser and seeing the server error which was

System.PlatformNotSupportedException: This operation requires IIS integrated pipeline mode.

Some googling turned up this page which said the error was caused by ASP.NET Development Server not supporting integrated pipeline mode.

You can change the server used by right clicking on the project, select properties, hit the web tab, and under the servers section select "Use Local IIS Web server".



回答2:

In my case IIS wasn't installed properly. I just had to reinstall it:

c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i