Class UriUtil
Static Utility methods for Uri support
Inheritance
Inherited Members
Namespace: EPiServer.Web
Assembly: EPiServer.dll
Version: 11.20.7Syntax
public static class UriUtil
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.String | url | The URL to add the parameter to. |
System.String | languageCode | The langauage code. |
Returns
Type | Description |
---|---|
System.String | 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.String | url | The original url (may include query string parameters) |
System.String | name | Name of the query string parameter (for example "status") |
System.String | val | The value of the query string parameter |
Returns
Type | Description |
---|---|
System.String | 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.Collections.Specialized.NameValueCollection | nvc | The collection containing the query data. |
Returns
Type | Description |
---|---|
System.String | 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.Collections.Specialized.NameValueCollection | nvc | The collection containing the query data. |
System.Text.Encoding | encoding | The encoding to use. |
Returns
Type | Description |
---|---|
System.String | 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.String | s1 | First part, may include scheme, host etc |
System.String | s2 | Second part, may include traling query string, fragment etc |
Returns
Type | Description |
---|---|
System.String | 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.String | uri | The URI string to test. |
Returns
Type | Description |
---|---|
System.Boolean | 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.String | uri | String representing the URI |
Returns
Type | Description |
---|---|
System.Boolean |
IsStringWellFormedUri(String)
Uses System.Uri.IsWellFormedUriString(System.String,System.UriKind) but treat relative links as http based links.
Declaration
public static bool IsStringWellFormedUri(string uriString)
Parameters
Type | Name | Description |
---|---|---|
System.String | uriString | The string to check for Uri complience |
Returns
Type | Description |
---|---|
System.Boolean | 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.String | url | The URL. |
Returns
Type | Description |
---|---|
System.String[] | 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.String | url | The URL. |
Returns
Type | Description |
---|---|
System.String[] | A string[3] array with the parts, or empty strings if no such part |