SignalR 2.0 in VS2012 registration and Dependency Injection

北慕城南 提交于 2019-12-06 15:59:11

You can still set the dependency resolver the same way you did in 1.1.3. However a better approach (does the same thing, just cleaner) would be to do:

app.MapSignalR(new HubConfiguration
{
    Resolver = new FunqDependencyResolver(container)
});

Note: app.MapSignalR() is the new RouteTable.Routes.MapHubs() for SignalR 2.0.0+, meaning you should no longer be doing RouteTable.Routes.MapHubs().

Now for your question about not having the Owin Startup class in VS2012, that's Ok! Just create a new blank class and copy n paste the code into your class. No other setup required.

Adamy

I used this approach below without changing HubConfiguration.

Using an existing IoC Container in SignalR 2.0

I shared the container for both SignalR and my web app, with resolving Hub from a CustomHubActivator, I can inject anything as parameters in my Hub.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!