I was working on defining generic controller for my web application, similar to the one explained in this question. The difference is that, in my case, controller routing prefix can contain one (ie: /Person), two or (more general) n segments (ie. /hr/Employee, ...). The answer from Jeff Fritz suggested that custom IControllerFactory should be implemented. However, since my routing structure is pretty complex and, therefore, hard to implement using RouteAttribute or MapRoute function in Program.cs, provided custom IControllerFactory was not called and, thus, not working. I have seen that controller could be registered using custom IApplicationModelProvider implementation. I was wondering how should a generic controller be registered for it to contain all actions, properties, filters, route values and selectors as expected by the default IApplicationModelProvider implementation?
Asked
Active
Viewed 38 times
0
Goran Petrović
- 13
- 5
-
Have you checked this [Docs](https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/application-model?view=aspnetcore-7.0#modify-the-controllermodel-description)? – Xinran Shen Jun 13 '23 at 07:57
-
@XinranShen I am currently lookung it up (to be more precise, I think I'll go with implementing my own `IControllerModelConvention` and providing custom `IApplicationFeatureProvider`) - I think it'll be both easier and cleaner than providing my own `IApplicationModelProvider`. Thanks for advice. – Goran Petrović Jun 13 '23 at 08:39