tags:

views:

19

answers:

1

In an ASP.NET MVC app I have a page with a dynamically generated list of links to different pages in the app. What is the best way for the controller to pass the link information to the view?

I want to keep the view as simple as possible and I'm assuming it's wrong to generate URLs in the controller (too UI specific, makes unit testing harder etc.) so for each link I currently pass an action string, a controller string and a RouteValueDictionary object. I then use URL.Action() in the view to create the link. Is this the best way to go or is there a neater way that doesn't involve three separate objects per link?

A: 

We pass just a RouteValueDictionary, instead of passing that + 2 strings. The RVD is allowed to have controller and action members. You can pass null for the action argument and the action member of the RVD will be used instead.

Craig Stuntz