tags:

views:

67

answers:

1

I'm trying to display a small panel during debugging in my application with various miscellaneous functionality. One thing i want it to contain is information about the current route.

I tried to look at Controller.RouteData but some of the properties were null.

 RouteData.Route          - null
 RouteData.RouteHandler   - null
 RouteData.Values         - has expected values corresponding to the URL

How do I get the value of 'Route' ?

I did see this post about URL debugging, but I don't think that helps because although I'm writing a debugging console I want the 'runtime' values and don't want to put in an extra layer of abstraction.

+1  A: 

I know this is an old question but still... you would like to to have the route-variables?

then you might get them via

ViewContext.RouteData.GetRequiredString("controller")

The name of the routevalue comes from the routing where you define all variables.

So you can access to Controller, Action, ID, whatever you have in the routing.

griti
@griti i dont rememebr exactly the situation but I'm no longer having the problem. RouteData.Route now has a value. I'm not sure if this changed for RTM or MVC 2 Preview 2. I dont think the problem was not being able to find the 'controller' name, but having a Route object
Simon_Weaver