Here is my dilemma. I have a collection of entities that I want to use to define as the starting point for a set of routes. For example, I want to give all of the users in my site their own "subsites" of the form mydomain.com/username, and then hang all of the UserController actions off of that.
Here is a rough example of what I am doing:
I have a "UserController", with action methods like "Index", "Profile" and "Bio".
public ActionResult Profile( int UserID )
{
User u = User.SingleOrDefault(u => u.UserID == UserID);
return View(u);
}
In RegisterRoutes() method, I do this:
foreach (User user in User.Find(u => u.Active == true))
{
routes.MapRoute(
"",
user.UserName + "/{action}",
new { controller="User", action="Index", UserID=user.UserID }
);
}
This works, and it works exactly as I want it to:
domain.com/[username]/Profile
domain.com/[username]/Bio
are now valid, working routes, and they can take in the UserID as the method parameter in the controller because each user gets their own route. Also, the default routes still work. Yay.
My question is, is this insane? I am creating an entry in the route table for every user in the system. How many routes is too many? Will this kill my server if there are over 10 users? 50? 1000?
And if this is insane, how else might I accomplish this goal?
Thanks in advance. I look forward to some input from the hive-mind.