How does SignalR register its HTTP Handler in the

2019-09-03 15:00发布

问题:

I have been looking for an hour and am baffled why the SignalR sample code actually works! I got it installed from nuget and it just works, which is good but cannot see how.

I cannot see anything in the global.asax or web.config to register the HttpHandler. I suspect this is probably a static constructor in some class and adds the handler (although again with no code using the class, that will not work), but cannot figure out without looking at the code - and for this, I dont feel like going through all the code.

So what have I missed?

Thanks for your help.

回答1:

OK, I figured out.

It uses PreApplicationStartMethod assembly attribute to load class Bootstrapper to register the HubModule.


UPDATE

In fact, in the version of samples I have, it is done in PreApplicationStart which is different from the source code that is in the GitHub (they have added support for OWIN, etc hence the loading has been abstracted out to separate hosting assemblies).



回答2:

Download the source code and look for the AspNetHost class.