SignalR 2.0 woes :(

So, before I get on my soapbox and complain, I want to begin by saying SignalR is awesomesauce to the MAX and I appreciate everything it does! Now I shall vent.

SignalR as many of you know, is a great .NET framework for easy seamless real-time messaging. You can do anything from a simple chat program to an intense responsive internet game. You can self host as well as host right within an ASP.NET project. With so many people using this framework, you would think they would be a little better about deprecating functionality or the way you do something like mapping the hubs t hat make the whole thing work in the first place?

So for those of you that are used to doing something like this in your Global.asax page before any other routes are created:

protected void Application_Start()
{
    RouteTable.Routes.MapHubs();
}

 

You no longer need this code. In fact, upon upgrading to 2.0-RC, you will get errors because that method no longer exists Sad smile. That was a huge change no? Any way, for all of you out there that spent a night or two figuring out what to do like I was, here is what you now do.

 

First add a class to your project called Startup.cs. Then within the class, add the following method:

 

public void Configuration(IAppBuilder app)
{
    // Any connection or hub wire up and configuration should go here
    app.MapSignalR();
}
This should find any hubs that you have declared and map them accordingly. Then in the Web.config file. The bold part is what needs to be added This
binds the Startup class to the libraries so they know where to find it.
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
    <appSettings>
    <add key="owin:AppStartup" value="SignalRChat.Startup, SignalRChat"/>
  </appSettings>
</configuration>

For more information on these steps, go here. After these steps, you should be all set.
 
A little warning would have been nice. Happy Coding Smile
 

Advertisements

About Gregg Coleman

I am Senior-level Software Engineer working primarily these days with .NET. I have a good working knowledge of ASP.NET MVC, Web Forms, WCF web services and Windows Services. I spend much of my time in the Web Services (SOAP and REST) world in my current job designing and implementing various SOA architectures. I have been in the software engineering industry for about 6 years now and will not now nor ever consider myself an "expert" in programming because there is always so much to learn. My favorite thing about designing software is there are always new emerging technologies and something to learn every day! My current job has me spending much of my job on the bleeding edge of technologies and changing gears all the time, so I'm never bored and always challenged. On my spare time I enjoy weight training, reading and venturing to new places near by. Of course programing and learning new technologies are another hobby of mine.
This entry was posted in .NET, ASP.NET, C#, Generics, SignalR and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s