16

我在 EPiServer 7.5(一个 MVC4 框架)中遇到了 SignalR 2.0 的一些问题。我得到的只是一个 404 错误

获取http://web.com/signalr/hubs 404(未找到)

我在 Windows 2012 R2 服务器上托管所有内容。另外值得注意的是,当从 Visual Studio 在 IIS Express 中运行所有内容时,该解决方案可以工作,但不能在 IIS 8.5 中运行

到目前为止我所做的是添加 SingalR 引用。

  • Microsoft.AspNet.SignalR.Client,2.0.0.0
  • Microsoft.AspNet.SignalR.Core,2.0.0.0
  • Microsoft.AspNet.SignalR.System.Web,2.0.0.0
  • 微软.OWin, 2.1.0.0
  • Microsoft.OWin.Host.SystemWeb,2.1.0.0
  • Microsoft.Owin.Security,2.0.0.0
  • 欧文,1.0.0.0

启动.cs

该启动是在应用程序启动时初始化的,因此似乎可以工作。

[assembly: OwinStartup(typeof(Web.Startup))]
namespace Web
{
    public class Startup
    {
        #region Local variables

        private static readonly ILog Logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        #endregion

        #region Methods

        /// <summary>
        /// Configure SignalR
        /// </summary>
        /// <param name="app"></param>
        public void Configuration(IAppBuilder app)
        {
            try
            {
                Logger.MethodCallEntry();

                // Any connection or hub wire up and configuration should go here
                //app.MapSignalR(); // Doesn't work either
                var hubConfiguration = new HubConfiguration
                {
                    EnableDetailedErrors = true,
                    EnableJavaScriptProxies = false
                };

                app.MapSignalR("/signalr", hubConfiguration);
            }
            catch (Exception ex)
            {
                Logger.Error("Failed to initialize or map SignalR", ex);
            }
            finally
            {
                Logger.MethodCallExit();
            }
        }

        #endregion
    }
}

脚本包含

<script src="/Static/Frameworks/Scripts/jquery-1.10.2.js"></script>
<script src="/Static/Frameworks/Scripts/knockout-3.0.0.js"></script>
<script src="/Static/Frameworks/Scripts/modernizr.2.7.0.js"></script>
<script src="/Static/Frameworks/Scripts/jquery.signalR-2.0.1.js"></script>
<!-- also tried path ~/signalr/hubs -->
<script src="/signalr/hubs"></script>

这不是从 1.x SignalR 更新的解决方案!

4

5 回答 5

18

只是想投入我的 2 美分。我遇到了这个错误,最终是因为我有

<add key="owin:AutomaticAppStartup" value="false" />

在我的 web.config 中。删除这条线为我解决了所有问题!

于 2014-08-05T21:34:56.287 回答
13

该错误与这篇文章中的完全相同 http://blogs.msdn.com/b/praburaj/archive/2013/12/02/owin-startup-class-not-detected.aspx

解决方案是完全清空 asp.net 缓存

在 PowerShell 中运行

net stop w3svc
Remove-Item -Path "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\*" -Force -Recurse
Remove-Item -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\*" -Force -Recurse
net start w3svc
于 2013-12-20T09:44:40.353 回答
6

我刚刚在新构建的 Win 2012R2 服务器上运行“MoveShape”演示时遇到了类似的问题。我通过添加角色/功能解决了这个问题:“Web Server (IIS)”->“Application Development”并选择“.NET Extensibility 4.5”、“ASP.NET 4.5”、“ISAPI Extensions”、“ISAPI Filters”和“WebSocket 协议”。

重新启动系统或 IIS 后,演示开始工作。

于 2014-05-08T17:20:55.713 回答
3

我的问题通过删除 nuget-package “Microsoft.Owin.Host.SystemWeb” 得到解决,它在 packages.config 中以 version="2.1.0" 引用并安装 version="3.0.1"。

在此版本中,owin 环境从未在服务器 2012r2 上的 iis8 上启动,并出现错误,即找不到命名空间“主机”。

Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Owin.Host.SystemWeb, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk.

Startup.cs(2,22): error CS0234: The type or namespace name 'Host' does not exist in the namespace 'Microsoft.Owin' (are you missing an assembly reference?) [*.csproj]
于 2015-09-15T09:50:22.560 回答
0

刚刚遇到同样的404问题。最后我更新了所有的 DLL,除了一个有问题的。我没有更新 Microsoft.AspNet.SignalR.SystemWeb.dll

于 2014-08-29T20:09:54.867 回答