.NET Signalr MapConnection已过时? [英] .NET Signalr MapConnection is Obsolete?

查看:58
本文介绍了.NET Signalr MapConnection已过时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.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
http://go.microsoft.com/fwlink/?LinkId=320578 for more details.'  
C:\fit\FailureInvestigationToolbox\App_Start\RouteConfig.cs

SignalR安装是否有问题,或者是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已过时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆