2017-02-24 91 views
0

我想在我的startup.cs中使用我的MVC核心項目上的IAppBuilder,以便我可以調用app.MapSignalR來實現我的signalR。不過,我似乎無法使用Owin在我的項目的任何地方,甚至當我包括using語句或聲明它像Owin'IAppBuilder'不存在於命名空間Microsoft.AspNetCore.Owin

Microsoft.AspNetCore.Owin.IAppBuilder 

我曾嘗試重新安裝的軟件包,但已於事無補。有誰知道可能是什麼原因造成的?

+0

SignalR不適用於ASP.Net核心呢。 – DavidG

+0

@DavidG我知道他們還沒有發佈完整的版本,但我使用的是最新的alpha版本。 –

+0

然後你完全使用錯誤的命名空間和中間件命令。你需要'services.AddSignalR()'和'app.UseSignalR(...)'。 SignalR不在Owin名稱空間中。 – DavidG

回答

1

看看在SignalR sample app這是repository的一部分,看看現在怎麼用這個。首先,Owin在這裏不是必需的,其次,你不使用MapSignalR()。在Startup.cs的相關部分:

public void ConfigureServices(IServiceCollection services) 
{ 
    //snip 

    services.AddSignalR(); 

} 

和:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, 
    ILoggerFactory loggerFactory) 
{ 
    //snip 

    app.UseSignalR(routes => 
    { 
     routes....... //Your routes here 
    }); 

} 
+0

對不起,我認爲這是答案。我按照你的建議開展工作。 –

+0

沒問題,沒有要求你標記任何東西或upvote,但感謝回來:) – DavidG

相關問題