Milos Mijatovic
Milos Mijatovic

Reputation: 975

/signalr/hubs 404 not found after update to MVC5

SignalR was working while project was ASP.NET MVC3. Now i upgraded it to MVC5 (not so easy to do, I must tell you).

Then I noticed that signalR was not working. I went by the book, reinstalled SignalR to version 2.1.0, installed OWIN (must-have for v2+) and added startup class to project.

This is my startup.cs class, it sits at project root folder:

[assembly: OwinStartup(typeof(SISTEM.Startup))]
namespace SISTEM
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR();
        }
    }
}

I see no problem here, but maybe i am missing something...

Now here is snippet from the hub:

namespace SISTEM
{
    public class PostingHub : Hub
    {
        public void Test(string hello)
        {
            Clients.All.hello(hello);
        }
    }
}

Then i reference generated proxys in view:

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

I inspect it in fiddler and i can see that /signalr/hubs request is generating HTTP 404 not found.

Now, i wasn't lazy, i tried several things:

Any help would be appreciated.

UPDATE: Response from /signalr/hubs

<!DOCTYPE html>
<html>
<head>
    <title>The resource cannot be found.</title>
    <meta name="viewport" content="width=device-width" />
</head>

<body bgcolor="white">

        <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>

        <h2> <i>The resource cannot be found.</i> </h2></span>

        <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

        <b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. &nbsp;Please review the following URL and make sure that it is spelled correctly.
        <br><br>

        <b> Requested URL: </b>/signalr/hubs<br><br>

        <hr width=100% size=1 color=silver>

        <b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34212

        </font>

</body>

[HttpException]: The controller for path &#39;/signalr/hubs&#39; was not found or does not implement IController.
at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType)
at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Upvotes: 6

Views: 11994

Answers (3)

Anton Lyhin
Anton Lyhin

Reputation: 1935

The SignalR js versions are supposed to be the same, but can be different. As a side effect you will find that error in browser console.

Check the version of SignalR library in Scripts folder and the one referenced in your view.

  • ~/Scripts/jquery.signalR-2.1.0.min.js (SignalR tutorial);
  • jquery.signalR-2.2.1.min.js is installed into scripts folder (nuget installation: install-package Microsoft.AspNet.SignalR).

Sometimes the most evident things are left unnoticed.

Upvotes: 2

Svein Terje Gaup
Svein Terje Gaup

Reputation: 1578

Like Milos said, clearing temp folder will probably fix the problem. I have created a script for doing this which I call powerreset.cmd which should be run As Administrator:

@echo off
@iisreset /stop
@robocopy e:\empty "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files" /PURGE
@robocopy e:\empty "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files" /PURGE
@iisreset /start

The e:\empty folder, which will be the source, and using purge with robocopy should then clear the temp files.

Upvotes: 3

Mox Shah
Mox Shah

Reputation: 3015

You need to install Microsoft.Owin.Host.SystemWeb package in the project

Verify this link

If package is not installed then install the following package from the Package Manager Console (PMC):

Install-Package Microsoft.Owin.Host.SystemWeb

UPDATE

It purely says that, its not able to detect your startup class, here are few more findings.

  • I believe this key is no more exist in config file <add key="owin:AutomaticAppStartup" value="false" />
  • Your application might be cached in temp folder, try deleting temporary files for your application.(Go to run > %TEMP% > CTRL + A > Delete)

This should definitely work, if it doesn't then try creating signalR in sample project.

Upvotes: 12

Related Questions