Calling Action Method From One Controller To Another Using ActionLink

In this blog we will learn how to call the action method which resides in the different controllers in ASP.NET MVC, first, we need to pass the following parameters in ActionLink are as follows, The following code snippet can be written in view or partial view.
  1. @Html.ActionLink("Index""ActionName""ControllerName"nullnew { id = "OT",style = "color: white" })  
In the preceding code,
  • The index is the ActionLink Name
  • ActionName is the View name or ActionResult Name.
  • ControllerName will be the name of our controller.
After implementing the code in parent view, the entire code will be look like as follows,
  1. @{  
  2.     ViewBag.Title = "Parentview";  
  3. }  
  5. <h2>Parentview</h2>  
  6. @*To call same same controller view*@  
  7. @Html.ActionLink("Index""ActionName")  
  9. @*To call another controller view*@  
  10. @Html.ActionLink("Index""ActionName""ControllerName"nullnew { id = "OT", style = "color: white" })  
  11. Summary  
I hope the preceding explanation will help you to learn how to call cross-controller action methods. If you have any suggestion then drop the comment in the comment box