在 Asp.Net 4.0 上使用 SignalR 和 angularjs

using SignalR and angularjs on Asp.Net 4.0

在过去两天我搜索 Google 没有任何进展后,我不得不在这里问这个问题。这是我的挑战:我有一个 Asp.Net 4.0 应用程序,它使用 Angularjs{我基本上只使用 Html 页}。我需要将 SignalR 集成到项目中以进行实时通信。我用谷歌搜索,我看到的只是上面带有 .Net 4.5 的示例。我无法使用其中任何一个,因为我的服务提供商不支持 .net 4.5,因此无法成功托管该应用程序。

我的挑战在于这条线

[assembly: OwinStartupAttribute(typeof(SignalRwithAngular.Startup))]

尝试设置启动时class。因为它抱怨

Error   18  The type or namespace name 'OwinStartupAttribute' could not be found (are you missing a using directive or an assembly reference?)  

我只需要一个示例,了解如何配置我的 angularjs 控制器以与集线器通信以及如何为 .Net 4.0 设置启动 class 请注意我无法使用 .Net 4.5,因为我的主机不支持它。

任何有用的link将不胜感激。

您是否包含 Microsoft.Owin 作为参考(通过 NuGet)?

经过多次谷歌搜索,我终于找到了出路 我完全删除了

[assembly: OwinStartupAttribute(typeof(SignalRwithAngular.Startup))]

从启动开始class

我通过 nuget 安装了适用于 .Net 4.0 的 SignalR 1.1.4 包

Install-Package Microsoft.AspNet.SignalR.Client -Version 1.1.4

在我的 Global.asax

 protected void Application_Start()
    {

        RouteTable.Routes.MapHubs();   // Must be added as the first line
         // Other Configs go here
    }

在我的 Startup.cs

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

}

我在构建后导航到

确认了它
http://localhost:port/signalr/hubs

现在一切正常....