signalR 2.0 took my MapHubs away

25 בJuly 2013

6 comments

Those of you who have used signalR from it’s first version and
hosted it on web application, probably know that they have to call
the MapHubs extension method of RouteCollection, as shown here:

protected void Application_Start(object sender, EventArgs e)

{

   RouteTable.Routes.MapHubs();

}

SignalR Logo

Those of you who has started trying out signalR version 2.0 must

have noticed that the extension method has gone. Instead you

have to do the following:

 

1. Create a class named <Hubs assembly name>.Startup

2. Create a method named Configuration within this class accepting an

   Owin.IAppBuilder
   as a parameter.

3. Inside the method implementation you may call the MapHub method

    of the IAppBuilder

   

The entire class should look like that:

using Owin;

 

namespace CallCenterWeb

{

    public class Startup

    {

        public void Configuration(IAppBuilder app)

        {

            app.MapHubs();

        }

    }

}

 

This makes the web-application-hosted and self-hosted signalR application

startup code looks the same. In self-hosted signalR you still need to call this

class, but that might be the only difference.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

6 comments

  1. Jerryb30 בJuly 2013 ב 20:43

    I came across the same issue, but ontop of that my fix dealt with updating which web server was used on my dev box.

    SignalR 2.0 throws a “System.PlatformNotSupportedException: This operation requires IIS integrated pipeline mode.” error, which is something Visual Studio Developer Server (Cassini) doesn’t support. Had to change my projects config to use the Local IIS Web server, then my hub started working.

    Wrote about my steps in this stack question.

    http://stackoverflow.com/questions/17959361/signalr-hubs-not-being-generated-when-upgrading-to-signalr-2-0-0-beta2

    Reply
  2. Ran Wahle31 בJuly 2013 ב 2:10

    Jerry, this problem is known, however you can use IIS express that supports integrated pipeline. Visual Studio 2012 has this settings by default in every ASP.NET project.

    Reply
  3. Andi24 בSeptember 2013 ב 17:58

    I’ve tried this, but get the error that Owin.IAppBuilder does not contain a Definition for MapHubs.

    Reply
  4. http://bottes-vernies-noires.shastadatadirector.com1 בNovember 2013 ב 19:47

    I do agree with all the ideas you have presented in your post. Thanks for the post.

    Reply
  5. Shahar19 בDecember 2013 ב 20:34

    I’ve installed singalR 2.0.
    there is no IAppBuilder, but Microsoft.Owin.Builder.AppBuilder

    and it doesn’t have the .MapSignalR method.
    what is going on with this version?

    Reply
  6. Serdar8 בJune 2014 ב 17:51

    Thanks a lot

    Reply