Как определить, соответствует ли произвольный URL-адрес определенный маршрут

Как определить, что строка соответствует конкретному именованному маршруту?

У меня есть такой маршрут:

routes.MapRoute(
    "FindYourNewRental",
    "find-your-new-rental/{market}/{community}.html",
    new { controller = "FindYourNewRental", action = "Community" }
    );

string url = "http://www.website.com/find-your-new-rental/northerncalifornia/sacramento.html"

Как я могу программно определить, соответствует ли строка 'url' этому маршруту? Примерно так:

// matches url with the named route "FindYourNewRental"
if (IsRouteMatch(url, "FindYourNewRental")) 
{
    // do something
}

public bool IsRouteMatch(string url, string routeName)
{
     // How do I code this function
}
16
задан Scott 20 January 2011 в 18:17
поделиться