LA.NET [EN]

Jul 24

Still on getting info about the current Route

Posted in ASP.NET MVC      Comments Off on Still on getting info about the current Route

In one of my previous posts, I’ve showed how you could access the Values property of the RouteData class to get info about the current controller and action. What I forgot to mention at the time was that you should use the GetRequiredString method to get the url parameter values that must be filled when you request a specific route. That means that I should have written the following code:

var controllerName = route.GetRequiredString( "controller" );
var actionName = route.GetRequiredString( "action" );

instead of the code that I presented on that post.