9er*_*9er 11 .net asp.net signalr
我是.Net和SignalR的新手.我正在查看一位前同事编写的一些代码,他将此行添加到Route Config,现在正在抛出错误,说它已过时,但我读过的所有文档都建议以这种方式映射连接.
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");
}
}
}
Run Code Online (Sandbox Code Playgroud)
错误是:
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
Run Code Online (Sandbox Code Playgroud)
有可能我的SignalR安装有问题,或者是IAppBuilder的方式来映射我应该做的事情......如果是这样的话?
我使用的是SignalR 2.0.3
ar.*_*gin 21
你可以使用这篇文章,
1.在全局应用程序类中,删除对MapHubs的调用.
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapHubs();
}
Run Code Online (Sandbox Code Playgroud)
2.右键单击解决方案,然后选择Add,New Item ....在对话框中,选择Owin Startup Class.将新类命名为Startup.cs.
3.使用以下代码替换Startup.cs的内容:
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(SignalRChat.Startup))]
namespace SignalRChat
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
Run Code Online (Sandbox Code Playgroud)