Sometimes it’s useful to be able to access the current RouteData from outside a controller, for instance in a library class. In webforms you could always do
HttpContext.Current
but in Asp.Net MVC it’s a bit less obvious how you get access to this data.
I’ve found the following code works:
RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current));
Whether there is an easier way or not I don’t know, but this will do me for now…
[...] to VoteAccess RouteData for the current Route from a library class in asp.net mvc (10/7/2009)Wednesday, October 07, 2009 from eliasbland.wordpress.comCurrent but in Asp. Net MVC it’s a bit [...]