Search Results for

    Show / Hide Table of Contents
    View Source

    Class UriUtility

    Provides utilities for manipulating URIs in the Umbraco routing context.

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.Routing
    Assembly: Umbraco.Core.dll
    Syntax
    public sealed class UriUtility

    Constructors

    View Source

    UriUtility(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 Source

    AppPath

    Gets the application path. Will be "/" or "/foo".

    Declaration
    public string? AppPath { get; }
    Property Value
    Type Description
    string
    View Source

    AppPathPrefix

    Gets the application path prefix. Will be "" or "/foo".

    Declaration
    public string? AppPathPrefix { get; }
    Property Value
    Type Description
    string

    Methods

    View Source

    MediaUriFromUmbraco(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.

    View Source

    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".

    View Source

    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.

    View Source

    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.

    View Source

    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.

    View Source

    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.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX