2

I am trying to use SignalR with aspnetcore 2.0.0 preview. The preview version is supposed to have support for signalR as per the release notes and I can add references to the "Microsoft.aspnetcoreSignalR" package.
However, I am unable to find the MapSignalR extension method or something like useSignalR() on the IApplicationBuilder.
Googling around for this gives lots of examples of the UseAppBuilder extension method. However, I still get stuck at MapSignalR with the below code:

using Microsoft.AspNetCore.Builder;

using Microsoft.Owin.Mapping;
using Microsoft.Owin.Helpers;
using Microsoft.Owin.Extensions;
using Microsoft.Owin.Builder;
using Owin;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace MyNamespace
{
    using AppFunc = Func<IDictionary<string, object>, Task>;

    public static class SignalRExtensions
    {


        public static IApplicationBuilder UseAppBuilder(this IApplicationBuilder app, Action<IAppBuilder> configure)
        {
            app.UseOwin(addToPipeline =>
            {
                addToPipeline(next =>
                {
                    var appBuilder = new AppBuilder();
                    appBuilder.Properties["builder.DefaultApp"] = next;

                    configure(appBuilder);

                    return appBuilder.Build<AppFunc>();
                });
            });

            return app;
        }

        public static void UseSignalR2(this IApplicationBuilder app)
        {
            app.UseAppBuilder(appBuilder => appBuilder.MapSignalR());
        }
    }
}

This is unable to find the MapSignalR extension method. Any thoughts on if I can find this some nuget package that will work with aspnetcore? Or is there a different mechanism to initialize signalR with aspnetcore 2.0.0 preview? I am using visual studio 2017 preview 15.3 with .Net core 2.0 preview installed.

Manish
  • 61
  • 1
  • 2
  • 6

1 Answers1

1

I basically hada the wrong set of nugget references. If I only have aspnetcore 2.0.0 preview 1 and the corresponding Microsoft.aspnetcore.signalR 1.0.0 preview package, there is already a UseSignalR() method available as an extension method for IApplicationBuilder and we don't need any of the above code.

Manish
  • 61
  • 1
  • 2
  • 6