Hello,
I'm making an ASP.NET MVC website and I have a certain group of forms that are related (let's called them Foo). My first attempt to organized them was to have this structure:
Controllers/FooController.cs
...and to have routes like this:
Foo/{type}/{action}/{id}
Unfortunately, since there are about 8 Foo sub-types, the FooController
was getting quite large and containing it's own sub-routing information. My next stab at it was to have this structure:
Controllers/Foo/Form1Controller.cs
Controllers/Foo/Form2Controller.cs
Controllers/Foo/Form3Controller.cs
...
With a controller for each form, which makes more sense to me since that's basically the layout I use for other forms in the app.
Unfortunately, I can't seem to find any easy way to make the route:
Foo/{controller}/{action}/{id}
...map to:
Controllers/Foo/{controller}Controller.cs
Basically what I want to do is tell ASP.NET MVC that I want all routes that match the Foo route to look in the Foo
subfolder of Controllers
for their controllers. Is there any easy way to do that via routing, or do I need to write my own IControllerFactory
?
Thanks.