aspnet5-workshop icon indicating copy to clipboard operation
aspnet5-workshop copied to clipboard

Extending MVC from a package

Open NickCraver opened this issue 8 years ago • 1 comments

We have several scenarios where we want to extend MVC applications from a plugin, which seems easier to do in ASP.Net Core MVC but still has bits to figure out a best approach on, can we add examples (or "no, you can't do that"s) for:

  • Adding routes & actions to an existing application, preferably just by including the package (e.g. the parent app looks for and adds, via LibraryManager?)
  • Adding views for those routes, that exist in the library package

We have use cases that lie on both sides of this and maybe there are simpler ways than we're approaching it. Practical use cases are things like dashboards where we'd like people to be able to write their own panels, pages, and post actions without touching the main application or involving a monolithic codebase there along with the community being able to share and contribute on these.

On the other side like our error handler we want to be able to drop in a few views in the app for easy access. Currently I'm approaching it as a simple route/action you drop in your application with a 1-liner to the package to handler the request...which is ultimately something like StringBuilder for shared libs with SystemWeb counterparts or possibly could include Razor dependencies on the Core MVC side of the fence.

How would you guys approach this? I'm curious if there are much better hooks or it's just not really an envisioned scenario you want to support. Either's fine, knowing either way helps.

NickCraver avatar Jan 21 '16 11:01 NickCraver

There's nothing built in for this so at the very list, you'll need some code to discover and load "extensions". There is no concept of a component with self contained controllers and views, it's something that always comes up and needs to be looked at in a future MVC release.

Orchard has done this and will likely be a source of inspiration when we explore extensibility points https://github.com/OrchardCMS/Orchard2/.

davidfowl avatar Jan 21 '16 14:01 davidfowl