Class UriExtensions
Provides extension methods to System.Uri.
Inheritance
Namespace: Umbraco.Extensions
Assembly: Umbraco.Core.dll
Syntax
public static class UriExtensionsMethods
View SourceEndPathWithSlash(Uri)
Rewrites the path of the uri so it ends with a slash.
Declaration
public static Uri EndPathWithSlash(this Uri uri)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Uri | uri | The uri. | 
Returns
| Type | Description | 
|---|---|
| System.Uri | The rewritten uri. | 
Remarks
Everything else remains unchanged.
GetAbsolutePathDecoded(Uri)
Gets the decoded, absolute path of the uri.
Declaration
public static string GetAbsolutePathDecoded(this Uri uri)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Uri | uri | The uri. | 
Returns
| Type | Description | 
|---|---|
| System.String | The absolute path of the uri. | 
Remarks
Only for absolute uris.
GetSafeAbsolutePath(Uri)
Gets the absolute path of the uri, even if the uri is relative.
Declaration
public static string GetSafeAbsolutePath(this Uri uri)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Uri | uri | The uri. | 
Returns
| Type | Description | 
|---|---|
| System.String | The absolute path of the uri. | 
Remarks
Default uri.AbsolutePath does not support relative uris.
GetSafeAbsolutePathDecoded(Uri)
Gets the decoded, absolute path of the uri, even if the uri is relative.
Declaration
public static string GetSafeAbsolutePathDecoded(this Uri uri)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Uri | uri | The uri. | 
Returns
| Type | Description | 
|---|---|
| System.String | The absolute path of the uri. | 
Remarks
Default uri.AbsolutePath does not support relative uris.
MakeAbsolute(Uri, Uri)
Transforms a relative uri into an absolute uri.
Declaration
public static Uri MakeAbsolute(this Uri uri, Uri baseUri)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Uri | uri | The relative uri. | 
| System.Uri | baseUri | The base absolute uri. | 
Returns
| Type | Description | 
|---|---|
| System.Uri | The absolute uri. | 
ReplaceHost(Uri, String)
Replaces the host of a uri.
Declaration
public static Uri ReplaceHost(this Uri uri, string host)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Uri | uri | The uri. | 
| System.String | host | A replacement host. | 
Returns
| Type | Description | 
|---|---|
| System.Uri | The same uri, with its host replaced. | 
Rewrite(Uri, String)
Rewrites the path of uri.
Declaration
public static Uri Rewrite(this Uri uri, string path)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Uri | uri | The uri. | 
| System.String | path | The new path, which must begin with a slash. | 
Returns
| Type | Description | 
|---|---|
| System.Uri | The rewritten uri. | 
Remarks
Everything else remains unchanged, except for the fragment which is removed.
Rewrite(Uri, String, String)
Rewrites the path and query of a uri.
Declaration
public static Uri Rewrite(this Uri uri, string path, string query)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Uri | uri | The uri. | 
| System.String | path | The new path, which must begin with a slash. | 
| System.String | query | The new query, which must be empty or begin with a question mark. | 
Returns
| Type | Description | 
|---|---|
| System.Uri | The rewritten uri. | 
Remarks
Everything else remains unchanged, except for the fragment which is removed.
TrimPathEndSlash(Uri)
Rewrites the path of the uri so it does not end with a slash.
Declaration
public static Uri TrimPathEndSlash(this Uri uri)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Uri | uri | The uri. | 
Returns
| Type | Description | 
|---|---|
| System.Uri | The rewritten uri. | 
Remarks
Everything else remains unchanged.
WithoutPort(Uri)
Removes the port from the uri.
Declaration
public static Uri WithoutPort(this Uri uri)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Uri | uri | The uri. | 
Returns
| Type | Description | 
|---|---|
| System.Uri | The same uri, without its port. |