I have an MVC website which has 3 main components
- Member area which has the path /Member/{controller}/{action}/{id}
- Individual pages which will respond to any subdomain, e.g. user1.example.com/{controller}/{action}/{id}, user2.example.com/{controller}/{action}/{id}
- Main website which will respond to any url under http://www.example.com/{controller}/{action}/{id}
What is the easiest way to handle the routes that will allow the above 3 items to co-exist? I have tried many MapRoutes from the global.asax.cs file and also making a new class based on RouteBase but not having much luck.
It sounds like you’re heading in the right direction – essentially you need to create a custom route which looks at the request and constructs the route value dictionary. Rather than reinvent the wheel though, someone has already created a nice implementation which allows you to include placeholders in the domain itself like so:
http://blog.maartenballiauw.be/post/2009/05/20/ASPNET-MVC-Domain-Routing.aspx