We've got an area on our site where people can sign up and be given their own page on the site which we want to host at ~/pageSlug. I've tried doing it with a rule in Global.asax, but that broke the fundamental default route that allows ~/Controller to map directly to the Index action. I'm not being allowed to put any kind of separator in front of the userSlug, so ~/p/pageSlug isn't really an option here.
In terms of getting the user pages added to the routes, I'm cycling through the pages at App_Start and explicitly adding them to the RoutesTable. This is working fine, and we've got AppPool refreshes set long enough to make this a once a day task. This does leave us with a 24-hour turnaround to "get pages live" for our users though, which I'm trying to solve.
Ideally, what I'd like to do is add the relevant route to the RouteTable dynamically once a user has signed up. I've tried doing that with:
RouteTable.Routes.Add(
RouteTable.Routes.MapRoute(
toAdd.UrlSlug + "Homepage",
toAdd.UrlSlug,
new { controller = "Controller", View = "View", urlSlug = toAdd.UrlSlug }
)
);
but that didn't seem to work. I can't find a solution anywhere else, and I'm sure my code is both horribly naive and betrays a lack of understanding of routing - please help!