Home >Backend Development >C++ >How to Create Action Links to Controllers Outside Their Folders in ASP.NET MVC?
When working with a controller in a location outside of its folder, it's necessary to create links to the desired methods. For the Html.ActionLink method, the following parameters are required:
ASP.NET MVC1:
public static string ActionLink(this HtmlHelper htmlHelper, string linkText, string controllerName, string actionName, object values, object htmlAttributes)
ASP.NET MVC2:
public static string ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object values, object htmlAttributes)
ASP.NET MVC3 :
public static string ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object values, object htmlAttributes)
Consider the following scenario:
public class ItemController:Controller { public ActionResult Login(int id) { return View("Hi", id); } }
To create a link to the Login method from a page outside the Item folder, use the following code:
The above is the detailed content of How to Create Action Links to Controllers Outside Their Folders in ASP.NET MVC?. For more information, please follow other related articles on the PHP Chinese website!