Take the 2-minute tour ×

I have a web application developed in ASP.NET MVC3 with C# and Razor.

I would like to call a specific Action Method of a specific Controller by using the ActionLink HTML helper. I know that the second parameter of ActionLink specifies the Action Method to be called from the Default route, which is the only one in my Global.asax file:

            "Default", // Route name
            new { controller = "Index", action = "Index", id = UrlParameter.Optional } // Parameter defaults

I would like to call the Download Action Method from the Home Controller instead of Index. This does not work:

@Html.ActionLink("Presentation", "Download", "Home", new { topicId = topic.TopicId } )

It requires as third parameter a type Object but I cannot find on the web any example.

What are the steps needed in order to call a specific Controller/ActionMethod? Shall I create another route in my Global.asas file?


share|improve this question

2 Answers 2

Try this one:

@Html.ActionLink("Download", "Download", new { controller = "Home",  Id = topic.TopicId });

The third parameter, object: routeValues, is used as dictionary in Asp.net MVC. Phil Haacked blogged about the decision for using object as route values.

Your overload function is not working because you are calling this method. String is also object. So, you are passing "Home" as routeValues and new { topicId = topic.Id} as htmlAttributes. :)

share|improve this answer
thanks for your answer. Is it something new in MVC3? In MVC2 I remember it worked as what I attempeted to do (the overload in my question) –  CiccioMiami Jul 27 '11 at 10:17
AFAIK, it should be the same in MVC2. :) –  Soe Moe Jul 27 '11 at 10:38

Is this the overload you require? You will need the 5th parameter for html attributes.

@Html.ActionLink("Presentation", "Download", "Home", new { topicId = topic.TopicId }, new { name="Download" )
share|improve this answer
thanks for your answer. Whay shall I use html attributes? Your overload will just specify an HTML name attribute with the "download" value( <a name="download", ...>. Besides being useful for binding I do not see the reason to use that –  CiccioMiami Jul 27 '11 at 10:20
Because that was this the overload that supported specifying all the parameters you wanted. You may just be able to use null as the final parameter but I wasn't certain so I just put null. Failing that give it an empty dictionary. –  Bob Vale Jul 27 '11 at 10:23

Your Answer


