To stop my application from getting cluttered I started working with areas. But now I always have to call:
http://localhost:49358/Document/Document/
instead of:
http://localhost:49358/Document/
How can I change my route to access the Controllers by name of the Area?
(no HomeController)
I have the following folder structure inside of my Project:
The code for my route to the Areas looks like this:
routes.MapRoute(name: "areaRoute",template: "{area:exists}/{controller=Home}/{action=Index}");
And I placed the [Area("Document")] Tag in my DocumentController.
Edit:
As suggested by Shyju and Jamie Taylor I went with the HomeControllers. (Thank you both for the quick answers and explanations)
My Structure now looks like this and the routing is working like expected:
For me it's still a bit dissapointing to have so many HomeControllers and Index Files. Navigating code isn't that easy anymore:
Edit2:
After getting too annoyed with all those Homecontrollers, I went with the solution suggested by Jamie Taylor and rearanged everything in a Features folder. It needs a bit more configuration but is much cleaner in my opinion.
It is also further explained in this Microsoft Article (Just skip the Area stuff):
https://msdn.microsoft.com/en-us/magazine/mt763233.aspx
My structure now looks like this and routing works like a charm and the controller names are still meaningful: