我做了一个方法来支持添加如下这样的对:
public static void MapRouteWithOptionalFormat(this RouteCollection routes, string name, string url, object defaults) { Route implicitRoute = routes.MapRoute(name + "-ImplicitFormat", url, defaults); implicitRoute.Defaults.Add("format", string.Empty); Route explicitRoute = routes.MapRoute(name + "-ExplicitFormat", url + ".{format}", defaults); }