SignalR /signalr/hubs 404 Not Found

2019-02-04 01:30发布

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 tried.

1) Changing the Script ref to:

script src="<%= ResolveUrl("~/signalr/hubs") %>" type="text/javascript"></script>

2) Modifying Web.Config to include :

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
    </modules>
</system.webServer>

3) Changing the invoke requests on IIS for UrlMappingsModule.

4) added SignalR.Hosting.AspNet.dll to see if that would help anything.

Not sure what else to try or check, any help or point in the right direction?

13条回答
Lonely孤独者°
2楼-- · 2019-02-04 01:59

If you are working on webforms, Please take the following steps

  1. In the webconfig:

    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true"/>
    
  2. In the page add reference to hub as

    <script src="/signalr/signalr/hubs"></script>
    

    instead of

    <script src="/signalr/hubs"></script>
    
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-02-04 01:59

Similar problem I had on IIS version, I fixed it by restarting AppPool, restart web and its working now.

查看更多
4楼-- · 2019-02-04 01:59

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)
查看更多
Luminary・发光体
5楼-- · 2019-02-04 02:00

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

查看更多
Luminary・发光体
6楼-- · 2019-02-04 02:07

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

查看更多
放荡不羁爱自由
7楼-- · 2019-02-04 02:08

Make sure your site's AppPool targets the correct version of .NET Framework.

查看更多
登录 后发表回答