segunda-feira, 14 de abril de 2014

How do I call a controller from another controller?

Hi!

Have you ever had this problem? You are on a certain page and you want to call a different Controller?

@Html.ActionLink([The name that will appear on the webpage], [The Action], [The name of the controller], [The parameters (Example.. new { code = item.code})], null)


Text, Action, Controller, Parameters, HttpObj.

The secret is to use the right overload. On the last parameter you have to pass null. If you use the overload with three parameters, for some reason I don't know, it doesn't work.

That's it!

Nenhum comentário:

Postar um comentário