.NET Signalr MapConnection已过时?

编程入门 行业动态 更新时间:2024-10-18 20:23:26
本文介绍了.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 go.microsoft/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已过时?

本文发布于:2023-07-17 03:26:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1128964.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NET   Signalr   MapConnection

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!