SignalR /signalr/hubs 404 Not Found

前端 未结 14 1311
时光说笑
时光说笑 2020-12-29 03:16

I am trying to deploy a SignalR site on IIS. Code all works fine in VS. But getting the 404 not found error trying to resolve signalr/hubs so far I have tri

相关标签:
14条回答
  • 2020-12-29 03:45

    there are potentially many causes of this 404 - a few common ones can be found by

    • Hit the url in the browser /signalr/hubs - if there is an error, you will see the full error come back.
    • check for duplication of HubName attribute if you have base class
    • ensure you have the correct version referenced in all projects (as to avoid binding errors)
    0 讨论(0)
  • 2020-12-29 03:46

    The reason of this 404 error is hubs are not mapped, previously it would have to be done as answered by SimonF. If you are using SignalR version 2 RouteTable.Routes.MapHubs(); is now obsolete. For mapping hubs you can create a startup class as below.

    [assembly: OwinStartup(typeof(WebApplication1.Startup))]
    namespace WebApplication1
    {
        public class Startup
        {
            public void Configuration(IAppBuilder app)
            {
                // Any connection or hub wire up and configuration should go here
                app.MapSignalR();
            }
        }
    }
    

    referenace : http://www.asp.net/signalr/overview/releases/upgrading-signalr-1x-projects-to-20

    0 讨论(0)
  • 2020-12-29 03:52

    For me the solution was to reinstall all the packages and restore all the dependecies.

    Open nuget powershell and use this command.

    Update-Package -Reinstall
    
    0 讨论(0)
  • 2020-12-29 03:54

    In my case, I lose some owin dependencies then I got the 404 NotFound error.

    When I added following dependencies, I retrieve the proxy javascript file clearly from expecting URL. Like URL:1111/singlar/hubs

    • Microsoft.Owin
    • Microsoft.Owin.Core
    • Microsoft.Owin.Host.SystemWeb
    • Microsoft.Owin.Security
    • Owin

    Hope the answer helps someone.

    0 讨论(0)
  • 2020-12-29 03:56

    The order of route registration matters. I had this exact problem and fixed it by ensuring my global.asax.cs looked like this:

    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteTable.Routes.MapHubs();
    
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
    }
    

    This was in a web site using SignalR, MVC and WebApi all together.

    0 讨论(0)
  • 2020-12-29 03:57

    Try adding a wildcard application map to your server to help map the unknown extension in the script URL "~/signalr/hubs"

    0 讨论(0)
提交回复
热议问题