7
votes

I'm participating in the ASP MVC project.

I want to use SignalR in the project but I don't want to use OWIN lib.

As I understand, SignalR is registered in the application using this piece of code:

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

How can I modify this to remove the dependency to OWIN?

I would like to use approach similar to RouteConfig.RegisterRoutes(RouteTable.Routes);

3
You can freely mix OWIN based and "traditional" ASP.Net in the same project. I can't think of any reason why you can't just put that piece of code in and get on with delivering value to your users.Damien_The_Unbeliever
I would like not to use OWIN if possible. I don't like when application has 100500 referenced assemblies. Currently I don't need OWIN, and the only library that requires OWIN is SignalR. But I know that it should be possible to get rid of this dependency.nZeus
@Damien_The_Unbeliever: actually there is. I am now facing a problem of running a MVC WebApplication (SignalR Server) in a Linux machine via Mono, and Microsoft.Owin.Host.SystemWeb is not fully implemented in Mono yet, which is required for WebApplication (self-hosted Owin SignalR Server is OK since it doesn't require Microsoft.Owin.Host.SystemWeb).brian
@nZeus - did you ever find a solution?Dirk Boer
@DirkBoer tbh I don't remember if I did. That was more than 5 years ago... Most probably that I didn't, and it wasn't that important for us, so we just kept a dependency.nZeus

3 Answers

3
votes

If you don't want the owin lib you can use SignalR 1.x.

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

First be sure to Get-Package within the Package Manager Console and remove all previous installments Uninstall-Package [Id] -RemoveDependencies as this should give you a clean slate.

What worked for me without assembly nor dependency issues was using NuGet to install Microsoft.AspNet.SignalR Version 1.1.4 into your App and DataAccess. Then add the following to your Global.asax file:

// Add this Library for MapHubs extension
using System.Web.Routing;

protected void Application_Start()
{
// This registers the default hubs route: ~signalr
// Simply add the line below WITHIN this function
RouteTable.Routes.MapHubs();
}

[Did this using Visual Studios 2015 Enterprise on 10/29/2015]

0
votes

I was able to do it following this Microsoft documentation: https://docs.microsoft.com/en-us/aspnet/core/signalr/hubs?view=aspnetcore-2.1

Their sample startup class is located here: https://github.com/aspnet/AspNetCore.Docs/blob/master/aspnetcore/signalr/hubs/sample/Startup.cs

public void ConfigureServices(IServiceCollection services)
{
   // other configure code
   // ...

   services.AddSignalR();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
   // other configure code
   // ...

   app.UseSignalR(route =>
   {
      route.MapHub<ChatHub>("/chathub");
   });
}