MapHubs not needed in SignalR 1.01?

2019-04-08 12:07发布

问题:

I am following the Hubs Quick Start Guide in the Signalr Wiki. I get an error in Global.asax, Application_Start on the line RouteTable.Routes.MapHubs().

A route named 'signalr.hubs' is already in the route collection. Route names must be unique. Parameter name: name

Maybe this is not needed anymore in 1.0.1? It worked fine in 1.0. It is also mentioned in the readme.txt from NuGet that we need the MapHubs command.

System.ArgumentException was unhandled by user code Message=A route named 'signalr.hubs' is already in the route collection. Route names must be unique. Parameter name: name Source=System.Web
ParamName=name StackTrace: at System.Web.Routing.RouteCollection.Add(String name, RouteBase item) at System.Web.Routing.RouteCollectionExtensions.Add[T](RouteCollection routes, String name, T item) at System.Web.Routing.RouteCollectionExtensions.MapOwinPath(RouteCollection routes, String name, String pathBase, Action`1 startup) at System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection routes, String name, String path, HubConfiguration configuration) at System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection routes, String path, HubConfiguration configuration) at System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection routes, HubConfiguration configuration) at System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection routes) at SignalrServer.Global.Application_Start(Object sender, EventArgs e) in C:\RC\Code\Signalr\SignalrServer\SignalrServer\Global.asax.cs:line 18 InnerException:

回答1:

You need it. Looks like you're calling it twice in your app, don't do that. If you're not explicitly calling it twice then you have and older version of signalr that used to call it for you lying around somewhere in your bin folder. Delete it all and it should work.



标签: signalr