UrlHelperExtensions.ActionLink Method

Definition

Generates an absolute URL for an action method, which contains the specified action name, controller name, route values, protocol to use, host name, and fragment. Generates an absolute URL if the protocol and host are non-null. See the remarks section for important security information.

public static string ActionLink (this Microsoft.AspNetCore.Mvc.IUrlHelper helper, string action = default, string controller = default, object values = default, string protocol = default, string host = default, string fragment = default);
public static string? ActionLink (this Microsoft.AspNetCore.Mvc.IUrlHelper helper, string? action = default, string? controller = default, object? values = default, string? protocol = default, string? host = default, string? fragment = default);
static member ActionLink : Microsoft.AspNetCore.Mvc.IUrlHelper * string * string * obj * string * string * string -> string
<Extension()>
Public Function ActionLink (helper As IUrlHelper, Optional action As String = Nothing, Optional controller As String = Nothing, Optional values As Object = Nothing, Optional protocol As String = Nothing, Optional host As String = Nothing, Optional fragment As String = Nothing) As String

Parameters

helper
IUrlHelper

The IUrlHelper.

action
String

The name of the action method. When null, defaults to the current executing action.

controller
String

The name of the controller. When null, defaults to the current executing controller.

values
Object

An object that contains route values.

protocol
String

The protocol for the URL, such as "http" or "https".

host
String

The host name for the URL.

fragment
String

The fragment for the URL.

Returns

The generated URL.

Remarks

The value of host should be a trusted value. Relying on the value of the current request can allow untrusted input to influence the resulting URI unless the Host header has been validated. See the deployment documentation for instructions on how to properly validate the Host header in your deployment environment.

Applies to