NET应用程序5使用SignalR

NET应用程序5使用SignalR

本文介绍了在ASP.NET应用程序5使用SignalR 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SignalR 3和ASP.NET 5人很好,直到同β7版本一起工作。现在微软表示SignalR 3是搁置,而人们不应该指望两到在不久的将来一起工作:

https://github.com/aspnet/SignalR-Server/issues/119

https://github.com/aspnet/SignalR-Server/issues/121

所以,问题:有没有一种方法,使在ASP.NET应用5至少SignalR 2工作


解决方案

发现本文中使用owin兼容的中间件通用的解决方案:
<一href=\"https://lbadri.word$p$pss.com/2014/11/01/asp-net-vnext-middleware-versus-owinkatana-middleware/\">https://lbadri.word$p$pss.com/2014/11/01/asp-net-vnext-middleware-versus-owinkatana-middleware/


  1. 引用 Microsoft.AspNet.Owin

  2. 插入下面的code到 Startup.Configure

app.UseOwin(a​​ddToPipeline =&GT;
{
    addToPipeline(下一=&GT;
    {
        VAR的AppBuilder =新的AppBuilder();
        appBuilder.Properties [builder.DefaultApp] =下一个;        appBuilder.MapSignalR();        返回appBuilder.Build&LT; AppFunc&GT;();
    });
});

SignalR 3 and ASP.NET 5 were working together nicely up until the beta7 version. Now Microsoft states that SignalR 3 is 'on hold', and one should not expect the two to work together in the near future:

https://github.com/aspnet/SignalR-Server/issues/119

https://github.com/aspnet/SignalR-Server/issues/121

So the question: is there a way to make at least SignalR 2 work in an ASP.NET 5 app?

解决方案

Found the general solution for using owin-compatible middleware in this article:https://lbadri.wordpress.com/2014/11/01/asp-net-vnext-middleware-versus-owinkatana-middleware/

  1. Reference the Microsoft.AspNet.Owin package
  2. Insert the following code into Startup.Configure:
app.UseOwin(addToPipeline =>
{
    addToPipeline(next =>
    {
        var appBuilder = new AppBuilder();
        appBuilder.Properties["builder.DefaultApp"] = next;

        appBuilder.MapSignalR();

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

这篇关于在ASP.NET应用程序5使用SignalR 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 07:48