How to Create ASP.NET SignalR Self Hosting in Windows Server

SignalR is an ASP.NET library that wraps up the above nasty code in a nice package with ability to handle JSON objects and convert them in .NET once the backend socket swallows. You add it as a DLL in the backend and create a class that extends Hub. You define 2 types of functions: push and pull. All the functions you write in there will be processed via C# reflection and it will ASP-generate a javascript file with all the callbacks, but now in javascript.

And now I want to tell you how to create ASP.NET SignalR Self Hosting on your Windows Server. Before that, please read carefully this requirement:

At the time of writing you’ll need to install the following NuGet packages from Package Manager Console in Visual Studio:
Install-Package Microsoft.AspNet.SignalR
Install-Package Microsoft.Owin.Hosting -Pre
Install-Package Microsoft.Owin.Host.HttpListener -Pre

You can delete the scripts folder added by SignalR, we’re really just after the assemblies:

So if you feel like only deploying the minimal assemblies you can remove anything else installed from those packages.

In this section we will create a console application for self hosting. Use the following procedure.
Step 1: Open Visual Studio and create a console application.
Step 2: Open the Package Manager Console from the Tools/Library Package Manager.
Step 3: Write the following command – install-package Microsoft.AspNet.SignalR.SelfHost -pre

Step 4: Now paste the following code in the Progran.cs file:

Step 5: Run your application.
Step 6: If you get an exception named System.Reflection.TargetInvocationException that was unhandled then it might be possible that you did not open Visual Studio as an Administrator.
Step 7: Stop the execution.

How to Create ASP.NET SignalR Self Hosting in Windows Server