How to implement Front-Controller design pattern in AspNet Core?

460 views Asked by At

Our Aspnet Core 2.2 app needs to implement the front-controller design pattern to select an arbitrary controller based on the app's internal logic. We are not as concerned with selecting an action because we intend to be as RESTful as possible with GET, POST, DELETE, etc. Here is an example of what we want to do:

Given a request to http://example.com/DomainObjectX/, one customer's business rules might use the DomainObjectXController, but another customer's business rule might provide CustomDomainObjectXController. We do not want to redirect the request but simply use a different controller to handle it the same URL.

Can custom middleware choose an arbitrary controller? I cannot find any examples where middleware does all the routing or passes the request along to the default route. My google-fu does not get me there.

Or should we use the application/controller model to select an a controller based on our app's business rules? Can someone point to an example that does that?

Or should we implement our own MatcherPolicy? I have not seen any examples that do this.

Any and others would probably work, but I'm not sure how/when to specify the arbitrary controller. So many things to learn ...

0

There are 0 answers