I'm in a very specific situation where I'd like to override the default ASP.NET Core ControllerFactory. I'd like to do this because I want to be in full control of what type of controller I handle each request with.
The scenario is:
- Request comes in with a specific subdomain
- Based on this subdomain, I want to resolve a Generic type controller in the factory
For example:
category.website.com
is called- We see it's of type
category
and will use the genericHomeController<T>
, using DI to inject the category so the type is ofHomeController<Category>
- The
HomeController<Category>
will use some generic methods on typeCategory
methods to render the homepage.
If I'm led to believe this link, a factory of type DefaultControllerFactory
is registered on startup of the application. This seems to not be overridable.
Any idea how I would go by this? The most logical options for us is using the old ASP.NET MVC version which allows you to set your own ControllerFactory, but we'd lose features like being able to use SpaServices
to prerender our Angular application.