Class UriUtil
Static Utility methods for Uri support
Inheritance
Namespace: EPiServer.Web
Assembly: EPiServer.dll
Version: 12.0.3Syntax
public static class UriUtil : Object
Methods
AddLanguageSelection(String, String)
Adds an epslanguage parameter to the query string of a URL.
Declaration
public static string AddLanguageSelection(string url, string languageCode)
Parameters
Type | Name | Description |
---|---|---|
System. |
url | The URL to add the parameter to. |
System. |
languageCode | The langauage code. |
Returns
Type | Description |
---|---|
System. |
The resulting URL as a string. |
AddQueryString(String, String, String)
Add query string parameter to given url
Declaration
public static string AddQueryString(string url, string name, string val)
Parameters
Type | Name | Description |
---|---|---|
System. |
url | The original url (may include query string parameters) |
System. |
name | Name of the query string parameter (for example "status") |
System. |
val | The value of the query string parameter |
Returns
Type | Description |
---|---|
System. |
The new url with the query string added. |
Remarks
This method will replace the value of an existing query string with the same name.
BuildQueryString(NameValueCollection)
Make a query string from a collection, no leading '?'
Declaration
public static string BuildQueryString(NameValueCollection nvc)
Parameters
Type | Name | Description |
---|---|---|
System. |
nvc | The collection containing the query data. |
Returns
Type | Description |
---|---|
System. |
The query string with URL encoding, or an empty string (not null) |
BuildQueryString(NameValueCollection, Encoding)
Builds a query string from a collection, no leading '?'
Declaration
public static string BuildQueryString(NameValueCollection nvc, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
System. |
nvc | The collection containing the query data. |
System. |
encoding | The encoding to use. |
Returns
Type | Description |
---|---|
System. |
The query string with URL encoding, or an empty string (not null) |
Combine(String, String)
Combine two HTTP-scheme URLs or paths. Use for simple and robust concatentation of slash-separated paths, even if part of a full http: URL.
Declaration
public static string Combine(string s1, string s2)
Parameters
Type | Name | Description |
---|---|---|
System. |
s1 | First part, may include scheme, host etc |
System. |
s2 | Second part, may include traling query string, fragment etc |
Returns
Type | Description |
---|---|
System. |
The correctly combined paths regardless of if s1 ends or not, or s2 starts or not, with "/" |
IsDataUri(String)
Determines whether the provided URI string is a data URI, e.g. data:image;base64,ZWF0IG15IHNob3J0cyE=.
Declaration
public static bool IsDataUri(string uri)
Parameters
Type | Name | Description |
---|---|---|
System. |
uri | The URI string to test. |
Returns
Type | Description |
---|---|
System. |
True if the string follows a data URI pattern; otherwise false. |
IsSchemeSpecified(String)
Checks if the provided string represents an absolute URI (begins with scheme)
Declaration
public static bool IsSchemeSpecified(string uri)
Parameters
Type | Name | Description |
---|---|---|
System. |
uri | String representing the URI |
Returns
Type | Description |
---|---|
System. |
IsStringWellFormedUri(String)
Uses System.
Declaration
public static bool IsStringWellFormedUri(string uriString)
Parameters
Type | Name | Description |
---|---|---|
System. |
uriString | The string to check for Uri complience |
Returns
Type | Description |
---|---|
System. |
true if string is considered a well formed Uri else false |
Split(String)
Splits the specified escaped URL into three parts: [0] - The [scheme][host][path] portion - before any fragment or query [1] - The query, if any, including the '?' [2] - The fragment, if any, including the '#'
Declaration
public static string[] Split(string url)
Parameters
Type | Name | Description |
---|---|---|
System. |
url | The URL. |
Returns
Type | Description |
---|---|
System. |
A string[3] array with the parts, or empty strings if no such part |
SplitNoDelim(String)
Splits the specified escaped URL into three parts: [0] - The [scheme][host][path] portion - before any fragment or query [1] - The query, if any, excluding the '?' [2] - The fragment, if any, excluding the '#'
Declaration
public static string[] SplitNoDelim(string url)
Parameters
Type | Name | Description |
---|---|---|
System. |
url | The URL. |
Returns
Type | Description |
---|---|
System. |
A string[3] array with the parts, or empty strings if no such part |