.Net和SignalR是我的新手.我正在查看由前同事编写的一些代码,他将此行添加到Route Config中,现在抛出错误,说它已过时,但所有文档我已阅读建议以这种方式映射连接.
I am new to .Net and SignalR. I am looking at some code written by a former coworker and he added this line to the Route Config which is now throwing errors saying its obsolete but all the documentation I have read suggest mapping connections in this way.
namespace FailureInvestigationToolbox { public class RouteConfig { public static void RegisterRoutes( RouteCollection routes ) { routes.IgnoreRoute( "{resource}.axd/{*pathInfo}" ); routes.MapRoute( name :"Default", url :"{controller}/{action}/{id}", defaults :new { controller = "fit", action = "Index", id = UrlParameter.Optional } ); RouteTable.Routes.MapConnection<TaskListPersistence>("taskpersist", "/taskpersist"); } } }错误是:
System.Web.Routing.SignalRRouteExtensions.MapConnection<T> (System.Web.Routing.RouteCollection, string, string)' is obsolete: 'Use IAppBuilder.MapSignalR<TConnection> in an Owin Startup class. See go.microsoft/fwlink/?LinkId=320578 for more details.' C:\fit\FailureInvestigationToolbox\App_Start\RouteConfig.csSignalR安装是否有问题,或者是IAppBuilder映射我应该做的事情的方式?如果是,怎么办?
Is it possible I have something wrong with my SignalR installation or is the IAppBuilder way of mapping things what I'm supposed to do...if so how?
我正在使用SignalR 2.0.3
I am using SignalR 2.0.3
推荐答案是的,您必须使用 IAppBuilder .添加一个Owin Startup 类,并在其 Configuration 方法中调用 app 参数上的 MapConnection< T> .那应该工作.在此处和此处.
Yes, you have to use IAppBuilder. Add a Owin Startup class, and in its Configuration method call MapConnection<T> on the app argument you receive. That should work. Check here and here.
更多推荐
.NET Signalr MapConnection已过时?
发布评论