Host 'n' is the number of SignalR hubs in ASP.NET (but MEF'd in)

I have an ASP.NET web project where I need to host several SignalR hubs that another MVC3 application will work with.

My main problem is that I do not know until the runtime is hosted in the Hub, since they must be MEF'd. DLLs containing the export (such as IXXXHub) will be located in the ASP.NET bin directory. At the moment there are 3 exported types: AHub, BHub and CHub, but there may be more, for example. DHUB may be implemented later.

I went through a SignalR sample showing how to post in an ASP.NET web project, so the part I got confused about is trying to get my MEF'd and post one from each of AHub / BHub / CHub. I looked at various approaches using Application_Start, but could not figure out how to do this.

Does anyone have any ideas?

0
source share
1 answer

In the end, I got the answer by simply adding the [ImportMany] attribute to the List object in the Global.asax class, and then adding the MEF catalog / container / ComposeParts code to the Application_Start function.

0
source

All Articles