HtmlHelperLinkExtensions Class

Link-related extensions for Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper.

Namespace
Microsoft.AspNetCore.Mvc.Rendering
Assemblies
  • Microsoft.AspNetCore.Mvc.ViewFeatures

Syntax

public class HtmlHelperLinkExtensions
class Microsoft.AspNetCore.Mvc.Rendering.HtmlHelperLinkExtensions

Methods

Returns an anchor (<a>) element that contains a URL path to the specified action.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the anchor element.

public static IHtmlContent ActionLink(this IHtmlHelper helper, string linkText, string actionName)
ActionLink(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String, System.Object)

Returns an anchor (<a>) element that contains a URL path to the specified action.

Arguments:
  • helper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • linkText (System.String) – The inner text of the anchor element. Must not be <code>null</code>.
  • actionName (System.String) – The name of the action.
  • routeValues (System.Object) – An System.Object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the System.Object. This System.Object is typically created using System.Object initializer syntax. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the route parameters.
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the anchor element.

public static IHtmlContent ActionLink(this IHtmlHelper helper, string linkText, string actionName, object routeValues)
ActionLink(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String, System.Object, System.Object)

Returns an anchor (<a>) element that contains a URL path to the specified action.

Arguments:
  • helper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • linkText (System.String) – The inner text of the anchor element. Must not be <code>null</code>.
  • actionName (System.String) – The name of the action.
  • routeValues (System.Object) – An System.Object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the System.Object. This System.Object is typically created using System.Object initializer syntax. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the route parameters.
  • htmlAttributes (System.Object) – An System.Object that contains the HTML attributes for the element. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the HTML attributes.
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the anchor element.

public static IHtmlContent ActionLink(this IHtmlHelper helper, string linkText, string actionName, object routeValues, object htmlAttributes)
ActionLink(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String, System.String)

Returns an anchor (<a>) element that contains a URL path to the specified action.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the anchor element.

public static IHtmlContent ActionLink(this IHtmlHelper helper, string linkText, string actionName, string controllerName)
ActionLink(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String, System.String, System.Object)

Returns an anchor (<a>) element that contains a URL path to the specified action.

Arguments:
  • helper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • linkText (System.String) – The inner text of the anchor element. Must not be <code>null</code>.
  • actionName (System.String) – The name of the action.
  • controllerName (System.String) – The name of the controller.
  • routeValues (System.Object) – An System.Object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the System.Object. This System.Object is typically created using System.Object initializer syntax. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the route parameters.
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the anchor element.

public static IHtmlContent ActionLink(this IHtmlHelper helper, string linkText, string actionName, string controllerName, object routeValues)
ActionLink(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String, System.String, System.Object, System.Object)

Returns an anchor (<a>) element that contains a URL path to the specified action.

Arguments:
  • helper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • linkText (System.String) – The inner text of the anchor element. Must not be <code>null</code>.
  • actionName (System.String) – The name of the action.
  • controllerName (System.String) – The name of the controller.
  • routeValues (System.Object) – An System.Object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the System.Object. This System.Object is typically created using System.Object initializer syntax. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the route parameters.
  • htmlAttributes (System.Object) – An System.Object that contains the HTML attributes for the element. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the HTML attributes.
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the anchor element.

public static IHtmlContent ActionLink(this IHtmlHelper helper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes)

Returns an anchor (<a>) element that contains a URL path to the specified route.

Arguments:
  • htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • linkText (System.String) – The inner text of the anchor element. Must not be <code>null</code>.
  • routeValues (System.Object) – An System.Object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the System.Object. This System.Object is typically created using System.Object initializer syntax. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the route parameters.
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the anchor element.

public static IHtmlContent RouteLink(this IHtmlHelper htmlHelper, string linkText, object routeValues)
RouteLink(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object, System.Object)

Returns an anchor (<a>) element that contains a URL path to the specified route.

Arguments:
  • htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • linkText (System.String) – The inner text of the anchor element. Must not be <code>null</code>.
  • routeValues (System.Object) – An System.Object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the System.Object. This System.Object is typically created using System.Object initializer syntax. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the route parameters.
  • htmlAttributes (System.Object) – An System.Object that contains the HTML attributes for the element. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the HTML attributes.
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the anchor element.

public static IHtmlContent RouteLink(this IHtmlHelper htmlHelper, string linkText, object routeValues, object htmlAttributes)
RouteLink(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String)

Returns an anchor (<a>) element that contains a URL path to the specified route.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the anchor element.

public static IHtmlContent RouteLink(this IHtmlHelper htmlHelper, string linkText, string routeName)
RouteLink(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String, System.Object)

Returns an anchor (<a>) element that contains a URL path to the specified route.

Arguments:
  • htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • linkText (System.String) – The inner text of the anchor element. Must not be <code>null</code>.
  • routeName (System.String) – The name of the route.
  • routeValues (System.Object) – An System.Object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the System.Object. This System.Object is typically created using System.Object initializer syntax. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the route parameters.
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the anchor element.

public static IHtmlContent RouteLink(this IHtmlHelper htmlHelper, string linkText, string routeName, object routeValues)
RouteLink(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String, System.Object, System.Object)

Returns an anchor (<a>) element that contains a URL path to the specified route.

Arguments:
  • htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • linkText (System.String) – The inner text of the anchor element. Must not be <code>null</code>.
  • routeName (System.String) – The name of the route.
  • routeValues (System.Object) – An System.Object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the System.Object. This System.Object is typically created using System.Object initializer syntax. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the route parameters.
  • htmlAttributes (System.Object) – An System.Object that contains the HTML attributes for the element. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the HTML attributes.
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the anchor element.

public static IHtmlContent RouteLink(this IHtmlHelper htmlHelper, string linkText, string routeName, object routeValues, object htmlAttributes)