.NET Signalr MapConnection is Obsolete?

前端 未结 3 1821
一向
一向 2021-02-14 01:51

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

相关标签:
3条回答
  • 2021-02-14 02:36

    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.

    0 讨论(0)
  • 2021-02-14 02:42

    To enable SignalR in your application, create a class called Startup with the following:

    using Owin;

    namespace MyWebApplication { public class Startup { public void Configuration(IAppBuilder app) { app.MapSignalR(); } } }

    0 讨论(0)
  • 2021-02-14 02:46

    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();
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题