Can you determine the name of the route followed from your webforms page?

asp.net, asp.net-3.5, asp.net-4.0, routes, webforms

Solution

It looks like Phil Haack has answered this question in a blog post on his site: http://haacked.com/archive/2010/11/28/getting-the-route-name-for-a-route.aspx

Problem

I have a ASP.NET 3.5 webforms project I have enabled routing over. I also have in the project a number of controls doing different things based on what page they are currently being shown in. It would seem that the most straightforward way to control this different behavior is to discover which route was used to load the page and then do things according to that. However, I can't seem to find a way to discover the route bar looking at the actual request URL and running a regex over it which isn't great. Does anyone know a way to look it up some other way? Update: there still doesn't appear to be a way to do this in ASP.NET 4.0. Hopefully someone else has figured this out?

Original source