tva*_*son 6

是.使用路由约束创建与用户匹配的路由:

routes.MapRoute(
            "User",                                 // Route name
            "{user}",                           // URL with parameters
            new { controller = "User", action = "Index", user = "" },  // Parameter defaults
            new { isUser = new MustBeUserConstraint() }
        );

public class MustBeUserConstraint : IRouteConstraint
{
    public bool Match
        (
            HttpContextBase httpContext, 
            Route route, 
            string parameterName, 
            RouteValueDictionary values, 
            RouteDirection routeDirection
        )
    {
        ...ensure that there is a user route value and validate that it is a user...
    }

}
Run Code Online (Sandbox Code Playgroud)