I have an MVC 4 (at the moment anyway) site which I want to offer to a number of customers. I thought I had clever idea and would create Custom controllers and then select which to use based on a parameter or something.
Each customer will have their own installation so the controller to use should be chosen at compile time and not run time ideally.
So the idea was to create a controller per Customer e.g. Customer1Controller
, Customer2Controller
etc. and then map it so all the customers would use http://myserver/Customer
.
I tried mapping all Customer/{action}
to Customer1/{action}
but I could not find anyway to map all actions in one statement and having one for every action seems a bit ugly.
My first idea was to try and use dependency injection but as the concrete classes are used for controllers that is apparently not an option. It has some other shortcomings as well.
The actual question is; is there anyway to do a "catch all" for actions? Something like this:
routes.MapRoute(
name: "Import",
url: "Customer/*/{id}",
defaults: new { controller = "Customer1", action = *, id = UrlParameter.Optional }
);
Thanks./H