c# - OwinStartup 和在 asp.net mvc 的 signalr 中启动

标签 c# signalr owin

我对 asp.net mvc 中的 SignalR 有疑问 我在下面添加一个包: enter image description here

并添加 Startup.cs

using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(Paksh.Startup))]
namespace Paksh
 {
   public class Startup
    {
      public static void ConfigureSignalR(IAppBuilder app)
       {
                  app.MapSignalR();
       }
     }
 }

但我得到错误:

The following errors occurred while attempting to load the app. - The OwinStartupAttribute.FriendlyName value '' does not match the given value 'ProductionConfiguration' in Assembly 'Paksh, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. - The given type or method 'ProductionConfiguration' was not found. Try specifying the Assembly. To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config. To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.

最佳答案

错误...

The given [...] method 'ProductionConfiguration' was not found.

表示OWIN Startup Class Detection正在根据您提供的类型 (Paksh.Startup) 寻找名为 ProductionConfiguration 的方法,但找不到。有些东西告诉我你的 web.config 中也有类似的东西:

<appSettings>  
  <add key="owin:appStartup" value="ProductionConfiguration" />       
</appSettings>

你有几种选择来解决这个问题:

  1. ConfigureSignalR 方法的名称更改为 ProductionConfiguration
  2. OwinStartupAttribute 中指定正确的方法名称: [程序集:OwinStartup(typeof(Paksh.Startup), "ConfigureSignalR")]

要了解 OWIN 启动类检测,请阅读更多 here .

关于c# - OwinStartup 和在 asp.net mvc 的 signalr 中启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22608019/

相关文章:

c# - 使用 LINQ to XML 解析深层嵌套属性时遇到问题

c# - 异步/等待和缓存

c# - 自定义 ConfigurationElement 中的 ConfigurationProperty 出现意外的 RegexStringValidator 失败

signalr - 启动时调用 SignalR 客户端方法

c# - NHibernate、Fluent NHibernate 和 Iesi.Collection 问题。接下来你会尝试什么?

asp.net - SignalR 长轮询传输

c# - SignalR 2.0 .NET 控制台客户端

asp.net - 当不匹配路由时,OWIN 中的 WebApi 总是返回 200 而不是 404

c# - 如何从 IOwinContext 获取 HttpRequestBase

authentication - 使用 OWIN Ws-Federation 包针对 ADFS 3.0 进行身份验证