SignalR 2.0 error /signalr/hubs 404 (Not Found) when using IIS
Asked Answered
G

5

16

I'm having some issues with SignalR 2.0 in EPiServer 7.5 (a MVC4 framework). All I get is a 404 error

GET http://web.com/signalr/hubs 404 (Not Found)

I'm hosting everything on a Windows 2012 R2 Server. Also noteworthy is that the solution works when running everything in IIS Express from Visual Studio but not in IIS 8.5.

What I've done so far is to add the SingalR references.

  • Microsoft.AspNet.SignalR.Client, 2.0.0.0
  • Microsoft.AspNet.SignalR.Core, 2.0.0.0
  • Microsoft.AspNet.SignalR.System.Web, 2.0.0.0
  • Microsoft.OWin, 2.1.0.0
  • Microsoft.OWin.Host.SystemWeb, 2.1.0.0
  • Microsoft.Owin.Security, 2.0.0.0
  • Owin, 1.0.0.0

Startup.cs

The startup is intitialized on application start so that seems to work.

[assembly: OwinStartup(typeof(Web.Startup))]
namespace Web
{
    public class Startup
    {
        #region Local variables

        private static readonly ILog Logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        #endregion

        #region Methods

        /// <summary>
        /// Configure SignalR
        /// </summary>
        /// <param name="app"></param>
        public void Configuration(IAppBuilder app)
        {
            try
            {
                Logger.MethodCallEntry();

                // Any connection or hub wire up and configuration should go here
                //app.MapSignalR(); // Doesn't work either
                var hubConfiguration = new HubConfiguration
                {
                    EnableDetailedErrors = true,
                    EnableJavaScriptProxies = false
                };

                app.MapSignalR("/signalr", hubConfiguration);
            }
            catch (Exception ex)
            {
                Logger.Error("Failed to initialize or map SignalR", ex);
            }
            finally
            {
                Logger.MethodCallExit();
            }
        }

        #endregion
    }
}

Script inclusion

<script src="/Static/Frameworks/Scripts/jquery-1.10.2.js"></script>
<script src="/Static/Frameworks/Scripts/knockout-3.0.0.js"></script>
<script src="/Static/Frameworks/Scripts/modernizr.2.7.0.js"></script>
<script src="/Static/Frameworks/Scripts/jquery.signalR-2.0.1.js"></script>
<!-- also tried path ~/signalr/hubs -->
<script src="/signalr/hubs"></script>

This is not a solution updated from 1.x SignalR!

Giraudoux answered 19/12, 2013 at 15:44 Comment(2)
@ThiagoCustodio Yea, the solution works fine in IIS Express in Visual Studio and I can debug the startup.cs as wellGiraudoux
Please check versions of SignalR as well #26751227Adam
G
13

The error was the exact same as in this post http://blogs.msdn.com/b/praburaj/archive/2013/12/02/owin-startup-class-not-detected.aspx

The solution was to totally empty the asp.net cache

Run this in PowerShell

net stop w3svc
Remove-Item -Path "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\*" -Force -Recurse
Remove-Item -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\*" -Force -Recurse
net start w3svc
Giraudoux answered 20/12, 2013 at 9:44 Comment(2)
My solutions work in various applications and host. My first app has being working for a year, but suddenly stopped working, while still work well in my local IIS. After running this script my app works again in IIS on 2012.Stringendo
I think the conflicts in the cache were caused by that I removed the website directory then uploaded new content when the Website were still running. And I replicated this problem. So the lesson is to shutdown the Website before updating it.Stringendo
C
18

just wanted to put my 2 cents in. I had this error, and it ended up being because i had

<add key="owin:AutomaticAppStartup" value="false" />

in my web.config. removing this line fixed everything up for me!

Canicula answered 5/8, 2014 at 21:34 Comment(2)
I was also looking for solution for same issue, thanks a,lot Phil this also works for me. :)Murrelet
Can you write your solution,becouse I have problem?Irrecusable
G
13

The error was the exact same as in this post http://blogs.msdn.com/b/praburaj/archive/2013/12/02/owin-startup-class-not-detected.aspx

The solution was to totally empty the asp.net cache

Run this in PowerShell

net stop w3svc
Remove-Item -Path "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\*" -Force -Recurse
Remove-Item -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\*" -Force -Recurse
net start w3svc
Giraudoux answered 20/12, 2013 at 9:44 Comment(2)
My solutions work in various applications and host. My first app has being working for a year, but suddenly stopped working, while still work well in my local IIS. After running this script my app works again in IIS on 2012.Stringendo
I think the conflicts in the cache were caused by that I removed the website directory then uploaded new content when the Website were still running. And I replicated this problem. So the lesson is to shutdown the Website before updating it.Stringendo
D
6

I just had a similar problem getting the "MoveShape" demo to work on a freshly built Win 2012R2 server. I resolved the problem by adding the role/features: "Web Server (IIS)" -> "Application Development" and selecting ".NET Extensibility 4.5", "ASP.NET 4.5", "ISAPI Extensions", "ISAPI Filters" and "WebSocket Protocol".

Once I restarted the system or IIS, the demo starting working.

Delegacy answered 8/5, 2014 at 17:20 Comment(0)
S
3

My problem was resolved by removing nuget-package "Microsoft.Owin.Host.SystemWeb", which was referenced in packages.config with version="2.1.0" and installing version="3.0.1".

With this version the owin environment was never started on the iis8 on server 2012r2 with the error, that the namespace "Host" was not found.

Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Owin.Host.SystemWeb, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk.

Startup.cs(2,22): error CS0234: The type or namespace name 'Host' does not exist in the namespace 'Microsoft.Owin' (are you missing an assembly reference?) [*.csproj]
Suburban answered 15/9, 2015 at 9:50 Comment(1)
Works for me. Thanks! Remove reference to Microsoft.Owin.Host.SystemWeb or set owin:AutomaticAppStartup to falseGaziantep
C
0

Just had the same 404 problem. Ended up I updated all the DLLs except for one which was problem. I didn't update Microsoft.AspNet.SignalR.SystemWeb.dll

Carmelacarmelia answered 29/8, 2014 at 20:9 Comment(1)
What versions did you have before and after?Giraudoux

© 2022 - 2024 — McMap. All rights reserved.