Share via


UrlHelperExtensions.PageLink Method

Definition

Generates an absolute URL for a page, which contains the specified pageName, pageHandler, 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 PageLink (this Microsoft.AspNetCore.Mvc.IUrlHelper urlHelper, string pageName = default, string pageHandler = default, object values = default, string protocol = default, string host = default, string fragment = default);
public static string? PageLink (this Microsoft.AspNetCore.Mvc.IUrlHelper urlHelper, string? pageName = default, string? pageHandler = default, object? values = default, string? protocol = default, string? host = default, string? fragment = default);
static member PageLink : Microsoft.AspNetCore.Mvc.IUrlHelper * string * string * obj * string * string * string -> string
<Extension()>
Public Function PageLink (urlHelper As IUrlHelper, Optional pageName As String = Nothing, Optional pageHandler 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

urlHelper
IUrlHelper

The IUrlHelper.

pageName
String

The page name to generate the url for. When null, defaults to the current executing page.

pageHandler
String

The handler to generate the url for. When null, defaults to the current executing handler.

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