I must be dense. After asking several questions on StackOverflow, I am still at a loss when it comes to grasping the new routing engine provided with ASP.NET MVC. I think I’ve narrowed down the problem to a very simple one, which, if solved, would probably allow me to solve the rest of my routing issues. So here it is:
How would you register a route to support a Twitter-like URL for user profiles?
www.twitter.com/username
Assume the need to also support:
-
the default
{controller}/{action}/{id}route. -
URLs like:
www.twitter.com/login
www.twitter.com/register
Is this possible?
What about
and then, in ProfilesController, there would be a function
In the function, if no user with the specified userName is found, you should redirect to the default {controller}/{action}/{id} (here, it would be just {controller}) route.
Urls like http://www.twitter.com/login should be registered before that one.