Tuesday, July 13, 2010

Reverse lookup Asp-Routing

When we use asp routing, it is easy to get the routed path from current request. 

var routedPath = HttpContext.Current.Request.Path;

But how to get the original path is a bit tricky. Here, how you do it.

var originalPath=   ((PageRouteHandler) System.Web.HttpContext.Current.Request.RequestContext.RouteData.RouteHandler).VirtualPath;