Search Results for

    Show / Hide Table of Contents
    View Source

    Class UriExtensions

    Provides extension methods to System.Uri.

    Inheritance
    System.Object
    Namespace: Umbraco.Extensions
    Assembly: Umbraco.Core.dll
    Syntax
    public static class UriExtensions

    Methods

    View Source

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

    View Source

    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.

    View Source

    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.

    View Source

    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.

    View Source

    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.

    View Source

    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.

    View Source

    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.

    View Source

    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.

    View Source

    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.

    View Source

    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.

    • Improve this Doc
    • View Source
    In This Article
    • Methods
      • EndPathWithSlash(Uri)
      • GetAbsolutePathDecoded(Uri)
      • GetSafeAbsolutePath(Uri)
      • GetSafeAbsolutePathDecoded(Uri)
      • MakeAbsolute(Uri, Uri)
      • ReplaceHost(Uri, String)
      • Rewrite(Uri, String)
      • Rewrite(Uri, String, String)
      • TrimPathEndSlash(Uri)
      • WithoutPort(Uri)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX