This should get you going in the right direction:
routes.MapRoute(
"ViewProfile",
"{username}",
new { controller = "User", action = "ViewProfile" },
// new { username = "\w+" } // consider using a username regex here
);
Note that you will need to update the controller
and action
values to match your application. The ViewProfile action should look something like this:
public ActionResult ViewProfile(string username) { }
Keep in mind that the above route is very greedy and you will have to make sure any other actions which need to be accessed within your application are placed higher up in the route definitions list. Also keep in mind that if a user should pick a username that conflicts with a route you've defined above the ViewProfile route, the user's profile will never be accessible via the rooted path because the other route will override it.