Class UriUtility
Provides utilities for manipulating URIs in the Umbraco routing context.
Inheritance
Namespace: Umbraco.Cms.Core.Routing
Assembly: Umbraco.Core.dll
Syntax
public sealed class UriUtility
Constructors
View SourceUriUtility(IHostingEnvironment)
Initializes a new instance of the UriUtility class.
Declaration
public UriUtility(IHostingEnvironment hostingEnvironment)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostingEnvironment | hostingEnvironment | The hosting environment. |
Properties
View SourceAppPath
Gets the application path. Will be "/" or "/foo".
Declaration
public string? AppPath { get; }
Property Value
| Type | Description |
|---|---|
| string |
AppPathPrefix
Gets the application path prefix. Will be "" or "/foo".
Declaration
public string? AppPathPrefix { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
View SourceMediaUriFromUmbraco(Uri)
Maps a media Umbraco URI to a public URI with virtual directory.
Declaration
public Uri MediaUriFromUmbraco(Uri uri)
Parameters
| Type | Name | Description |
|---|---|---|
| Uri | uri | The media URI. |
Returns
| Type | Description |
|---|---|
| Uri | The public media URI. |
ResolveUrl(string)
Resolves a relative URL to an absolute URL.
Declaration
public string ResolveUrl(string relativeUrl)
Parameters
| Type | Name | Description |
|---|---|---|
| string | relativeUrl | The relative URL to resolve. |
Returns
| Type | Description |
|---|---|
| string | The resolved URL. |
Remarks
If browsing http://example.com/sub/page1.aspx then ResolveUrl("page2.aspx") returns "/page2.aspx".
ToAbsolute(string)
Converts a relative URL to an absolute URL by prepending the application path prefix.
Declaration
public string ToAbsolute(string url)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The relative URL. |
Returns
| Type | Description |
|---|---|
| string | The absolute URL with the application path prefix. |
ToAppRelative(string)
Converts a virtual path to an application-relative path by stripping the virtual directory if present.
Declaration
public string ToAppRelative(string virtualPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | virtualPath | The virtual path. |
Returns
| Type | Description |
|---|---|
| string | The application-relative path. |
UriFromUmbraco(Uri, RequestHandlerSettings)
Maps an internal Umbraco URI to a public URI with virtual directory and appropriate suffixes.
Declaration
public Uri UriFromUmbraco(Uri uri, RequestHandlerSettings requestConfig)
Parameters
| Type | Name | Description |
|---|---|---|
| Uri | uri | The internal Umbraco URI. |
| RequestHandlerSettings | requestConfig | The request handler settings. |
Returns
| Type | Description |
|---|---|
| Uri | The public URI. |
UriToUmbraco(Uri)
Maps a public URI to an internal Umbraco URI without virtual directory, lowercased.
Declaration
public Uri UriToUmbraco(Uri uri)
Parameters
| Type | Name | Description |
|---|---|---|
| Uri | uri | The public URI. |
Returns
| Type | Description |
|---|---|
| Uri | The internal Umbraco URI. |