Url Class
https://url.spec.whatwg.org/#url-class
public sealed class UrlSee also
Constructors
| Name | Description |
|---|---|
| Url(string, string?) | Creates a URL by parsing the given string against the optional base URL; throws a TypeError when it is invalid. |
Url(string, string?)
Url.csCreates a URL by parsing the given string against the optional base URL; throws a TypeError when it is invalid.
Properties
| Name | Description |
|---|---|
| Hash | Gets or sets the fragment of the URL, prefixed by #, or an empty string when it is empty. |
| Host | Gets or sets the host of the URL, followed by the port when it is not the default one. |
| Hostname | Gets or sets the host of the URL, without the port. |
| Href | Gets or sets the serialized URL; setting an invalid URL throws a TypeError. |
| Origin | Gets the serialized origin of the URL. |
| Password | Gets or sets the percent-encoded password of the URL. |
| Pathname | Gets or sets the serialized path of the URL. |
| Port | Gets or sets the port of the URL, or an empty string when it is the default one. |
| Protocol | Gets or sets the scheme of the URL followed by a colon. |
| Search | Gets or sets the query of the URL, prefixed by ?, or an empty string when it is empty. |
| SearchParams | Gets the URLSearchParams object associated with the query of the URL. |
| Username | Gets or sets the percent-encoded username of the URL. |
Hash
Url.csGets or sets the fragment of the URL, prefixed by #, or an empty string when it is empty.
public string Hash { get; set; }Host
Url.csGets or sets the host of the URL, followed by the port when it is not the default one.
public string Host { get; set; }Hostname
Url.csGets or sets the host of the URL, without the port.
public string Hostname { get; set; }Href
Url.csGets or sets the serialized URL; setting an invalid URL throws a TypeError.
public string Href { get; set; }Origin
Url.csGets the serialized origin of the URL.
public string Origin { get; }Password
Url.csGets or sets the percent-encoded password of the URL.
public string Password { get; set; }Pathname
Url.csGets or sets the serialized path of the URL.
public string Pathname { get; set; }Port
Url.csGets or sets the port of the URL, or an empty string when it is the default one.
public string Port { get; set; }Protocol
Url.csGets or sets the scheme of the URL followed by a colon.
public string Protocol { get; set; }Search
Url.csGets or sets the query of the URL, prefixed by ?, or an empty string when it is empty.
public string Search { get; set; }SearchParams
Url.csGets the URLSearchParams object associated with the query of the URL.
public UrlSearchParams SearchParams { get; }Username
Url.csGets or sets the percent-encoded username of the URL.
public string Username { get; set; }Methods
| Name | Description |
|---|---|
| CanParse(string, string?) | Returns whether the given string can be parsed as a URL against the optional base URL. |
| CreateObjectUrl(Blob) | Creates a blob: URL referencing a blob (https://w3c.github.io/FileAPI/#dfn-createObjectURL), until it is revoked or the document of the current global object is destroyed. The URL can be navigated to (e.g. the src of an iframe) by the documents of the browsing context group of the current global object. |
| CreateObjectUrl(MediaSource) | Creates a blob: URL referencing a media source (https://w3c.github.io/media-source/#mediasource-object-url), until it is revoked: a media element whose src attribute (or the one of a source child) is set to the URL attaches the source. The URL of a media source constructed in a dedicated worker cannot be used (the source is attached by its MediaSource.Handle). |
| Parse(string, string?) | Returns the URL obtained by parsing the given string against the optional base URL, or null when it is invalid. |
| RevokeObjectUrl(string) | Revokes a blob: URL created by Url.CreateObjectUrl (https://w3c.github.io/FileAPI/#dfn-revokeObjectURL). |
| ToJson() | Returns the serialized URL, as toJSON() does. |
| ToString() | Returns a string that represents the current object. |
CanParse(string, string?)
Url.csCreateObjectUrl overloads
CreateObjectUrl(Blob)
Url.csCreates a blob: URL referencing a blob (https://w3c.github.io/FileAPI/#dfn-createObjectURL), until it is revoked or the document of the current global object is destroyed. The URL can be navigated to (e.g. the src of an iframe) by the documents of the browsing context group of the current global object.
CreateObjectUrl(MediaSource)
Url.csCreates a blob: URL referencing a media source (https://w3c.github.io/media-source/#mediasource-object-url), until it is revoked: a media element whose src attribute (or the one of a source child) is set to the URL attaches the source. The URL of a media source constructed in a dedicated worker cannot be used (the source is attached by its MediaSource.Handle).
public static string CreateObjectUrl(MediaSource obj)Parse(string, string?)
Url.csRevokeObjectUrl(string)
Url.csRevokes a blob: URL created by Url.CreateObjectUrl (https://w3c.github.io/FileAPI/#dfn-revokeObjectURL).
ToJson()
Url.csReturns the serialized URL, as toJSON() does.
public string ToJson()