Reputation: 1667
I have an MVC website which has 3 main components
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.
Upvotes: 2
Views: 331
Reputation: 3265
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:
routes.Add("DomainRoute", new DomainRoute(
"{controller}.example.com", "{action}/{id}",
new { controller = "Home", action = "Index", id = "" }));
http://blog.maartenballiauw.be/post/2009/05/20/ASPNET-MVC-Domain-Routing.aspx
Upvotes: 1