Dela via


IUrlHelper.IsLocalUrl(String) Method

Definition

Returns a value that indicates whether the URL is local. A URL is considered local if it does not have a host / authority part and it has an absolute path. URLs using virtual paths ('~/') are also local.

public:
 bool IsLocalUrl(System::String ^ url);
public bool IsLocalUrl (string url);
public bool IsLocalUrl (string? url);
abstract member IsLocalUrl : string -> bool
Public Function IsLocalUrl (url As String) As Boolean

Parameters

url
String

The URL.

Returns

true if the URL is local; otherwise, false.

Examples

For example, the following URLs are considered local:

/Views/Default/Index.html
~/Index.html

The following URLs are non-local:

../Index.html
http://www.contoso.com/
http://localhost/Index.html

Applies to