You can try extending the HttpRequestBase and overriding the Uri property so that you can assign your Uri to the property on demand. Then override the HttpContextBase so that you can set the Request property in context. Then you can use the GetRouteData () method in the RouteCollection class to get a suitable RouteValueDictionary. Note that RouteCollection is available as a static property of the RouteTable class.
var myRequest = new MyRequest( myUri ); var myContext = new MyContext( myRequest ); var routeData = RouteTable.Routes.GetRouteData( myContext );
Update
In your use case (comments) you can simply map the controller / action:
if (myUri.ToString().ToLower().Contains( "/controller/action" )) { return RedirectToAction( action, controller, new { ...route data } ); } else { return Redirect( "http://www.example.com/default" ); }
source share