Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Signalr MapConnection is Obsolete?

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");
    }
}
}

The error is:

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

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?

I am using SignalR 2.0.3

like image 537
9er Avatar asked May 13 '14 15:05

9er


1 Answers

You can use this article ,

1.In the global application class, remove the call to MapHubs.

protected void Application_Start(object sender, EventArgs e)
{
 RouteTable.Routes.MapHubs();
}

2.Right-click the solution, and select Add, New Item.... In the dialog, select Owin Startup Class. Name the new class Startup.cs.

3.Replace the contents of Startup.cs with the following code:

using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(SignalRChat.Startup))]
namespace SignalRChat
{

    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR();
        }
    }
}
like image 166
ar.gorgin Avatar answered Oct 04 '22 18:10

ar.gorgin