Model view controller 从路由集合获取URL

Model view controller 从路由集合获取URL,model-view-controller,collections,routes,Model View Controller,Collections,Routes,我正在以以下格式加载到MVC project上的route collection多个路由: routes.MapRoute( name: string.Format("{0}/{1}/{2}/{3}", controller, action, seo.PageRefProductType, seo.PageRefProductId), url: seo.FriendlyUrl, defaults: new { controll

我正在以以下格式加载到MVC project上的route collection多个路由:

 routes.MapRoute(
           name: string.Format("{0}/{1}/{2}/{3}", controller, action, seo.PageRefProductType, seo.PageRefProductId),
           url: seo.FriendlyUrl, 
           defaults: new { controller = controller, action = action, id=seo.PageRefProductId}
           );
当我使用APIController访问它时,我可以使用Url.Route(从System.Web.Http.Routing.UrlHelper派生)来获取该路由中的友好Url

我的问题是,当我没有URL.Route方法时,例如当我不在控制器中时,如何访问该URL

这是我在global.asax上的应用程序启动:

  protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        GlobalConfiguration.Configure(WebApiConfig.Register);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

        //loading the routes here:
        RouteConfig.RegisterRoutes(RouteTable.Routes);

        BundleConfig.RegisterBundles(BundleTable.Bundles);
        AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;
        LocalSiteManager.UpdateLatestReviewInManagedData();

        //cache - Here is where I want to use the routes
        LocalWorkFlow.StaticCache.LoadStaticCache(RouteTable.Routes);

    }
以下是我想要的LoadStaticCache:

public static void LoadStaticCache(RouteCollection routes)
{
    //get the URL of specific route by its' name
    string myUrl = routes["myUrlName"].Url;
}

我现在所做的是将每个路由名称和url添加到一个目录中,其中我的键是路由名称,值是url,然后我可以从我想要的任何地方访问它