views:

89

answers:

3

I am trying to understand what this RouteLink does. Say, in my Global.asax, I have the default route for MVC

 routes.MapRoute(
            "Default",                                              // Route name
            "{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );

and on a View page, I do

<%=Html.RouteLink("Dinners", "Default", new { controller="Dinners", action="Details", id="1"} %>

Why it does not generate the link /Dinners/Details/1 but thrown an exception?

Thanks. Gil.

+1  A: 

When using the default route, you really do not want to call it by name. Instead of using the RouteLink methods, you should use ActionLink, which allows you to specify the controller and names:

Html.ActionLink("See dinners!", "Default", "Dinners", new { id = 1 });
Jørn Schou-Rode
A: 

I think my previous answer was a bit premature :-(.

When trying out your approach in a fresh project, I get the behaviour you would expect. What kind of error are you seeing?

Rune
A: 

It is a missing close parenthesis as SLaks suggested. Problem solved. Thanks!

gilbertc