Base solution for your next web application
Open Closed

Signalr in lazy module #7773


User avatar
0
ivanosw1 created

Hi, I've differents optional modules loaded as plugin (plugins directorty), Some of these has SignalR feature.

Every installation can have zero, one or all modules, so I can't register in advanced on startup class. How can I register on demand signalr routes like routes.MapHub<MyChatHub>("/signalr-myChatHub"); // Prefix with '/signalr'?

Thank you.


2 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ivanosw1

    I think it is not possible to define SignalR route in your plugin module since Startup.cs is executed before modules loaded.

    Maybe you can store paths in somewhere for each plugin module and get them in startup and then define SignalR routes.

    What do you think ?

  • User Avatar
    0
    ivanosw1 created

    Hi @ismcagdas, Yes, you're right. I think I've found a solution based on your comment. In the main code I've defined an attribute class the is applied on my signalr module. In startup class, through reflection, I can discover all classes with that attribute and register in the signalr routes.

    It works and I think it could be part of aspnet zero without much effort. :-)

    Thank you