Asp.Net Core: Have to find a way to dynamically register EDM & ODataControllers *after* app.build event()

Sky S 1 Reputation point
2022-11-24T20:25:28.517+00:00

Hi,

We're in a bit of a (real) bind.

We need to demonstrate to stakeholders that Asp.Net Core stack is still a viable platform for this project which MUST loading plugins containing an set of WebAPI and OData Controllers unknown at startup. Due to our lack of success so far everybody is getting jumpy.

Specifically:

  • one solution, one project
  • with 2 ODataControllers,
  • One Convention based EDM model registered during startup, pointing to only one of the two ODataControllers
  • such that when invoked (ie way after Build),
  • registers a second EDM model that points to the second ODataController.
  • proving:
  • ODataControllers can be registered late (as if they had just been made available via a plugin)

We have not envisioned yet know how to prove the same with two simple WebAPI (not OData) Controllers -- as they are automatically spotted/found/registered at startup.

For bonus points, if anyone knows any/elegant? way to register Services late (eg: those that came in via the Plugin)...but I think StackOverflow is littered with that question, and no straight forward answers.

Thank you!

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,378 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 61,181 Reputation points
    2022-11-28T18:58:09.993+00:00

    your goal is not clear. controllers are already a plugin model. you just publish to the bin folder and restart.

    if you need dynamic loading and routing then:

    to implement true plugins see:

    https://learn.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support

    you would have a master controller that called the proper plugin.

    for dynamic routing see:

    https://medium.com/[@](/users/na/?userId=0e4b2b59-4001-0003-0000-000000000000)/dynamic-controller-routing-in-asp-net-5-ac81a6bb8a95