Search Results for

    Show / Hide Table of Contents
    View Source

    Class UrlProvider

    Provides URLs.

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.Routing
    Assembly: Umbraco.Core.dll
    Syntax
    public class UrlProvider : IPublishedUrlProvider

    Constructors

    View Source

    UrlProvider(IUmbracoContextAccessor, IOptions<WebRoutingSettings>, UrlProviderCollection, MediaUrlProviderCollection, IVariationContextAccessor, IDocumentNavigationQueryService, IPublishedContentStatusFilteringService)

    Initializes a new instance of the UrlProvider class with an Umbraco context and a list of URL providers.

    Declaration
    public UrlProvider(IUmbracoContextAccessor umbracoContextAccessor, IOptions<WebRoutingSettings> routingSettings, UrlProviderCollection urlProviders, MediaUrlProviderCollection mediaUrlProviders, IVariationContextAccessor variationContextAccessor, IDocumentNavigationQueryService navigationQueryService, IPublishedContentStatusFilteringService publishedContentStatusFilteringService)
    Parameters
    Type Name Description
    IUmbracoContextAccessor umbracoContextAccessor

    The Umbraco context accessor.

    IOptions<WebRoutingSettings> routingSettings

    Routing settings.

    UrlProviderCollection urlProviders

    The list of URL providers.

    MediaUrlProviderCollection mediaUrlProviders

    The list of media URL providers.

    IVariationContextAccessor variationContextAccessor

    The current variation accessor.

    IDocumentNavigationQueryService navigationQueryService

    The query service for the in-memory navigation structure.

    IPublishedContentStatusFilteringService publishedContentStatusFilteringService

    Properties

    View Source

    Mode

    Gets or sets the provider URL mode.

    Declaration
    public UrlMode Mode { get; set; }
    Property Value
    Type Description
    UrlMode

    Methods

    View Source

    GetMediaUrl(Guid, UrlMode, string?, string, Uri?)

    Gets the URL of a media item.

    Declaration
    public string GetMediaUrl(Guid id, UrlMode mode = UrlMode.Default, string? culture = null, string propertyAlias = "umbracoFile", Uri? current = null)
    Parameters
    Type Name Description
    Guid id
    UrlMode mode
    string culture
    string propertyAlias
    Uri current
    Returns
    Type Description
    string
    View Source

    GetMediaUrl(IPublishedContent?, UrlMode, string?, string, Uri?)

    Gets the URL of a media item.

    Declaration
    public string GetMediaUrl(IPublishedContent? content, UrlMode mode = UrlMode.Default, string? culture = null, string propertyAlias = "umbracoFile", Uri? current = null)
    Parameters
    Type Name Description
    IPublishedContent content

    The published content.

    UrlMode mode

    The URL mode.

    string culture

    The variation language.

    string propertyAlias

    The property alias to resolve the URL from.

    Uri current

    The current absolute URL.

    Returns
    Type Description
    string

    The URL for the media.

    Remarks

    The URL is absolute or relative depending on mode and on current.

    If the media is multi-lingual, gets the URL for the specified culture or, when no culture is specified, the current culture.

    If the provider is unable to provide a URL, it returns string.Empty.

    View Source

    GetOtherUrls(int)

    Gets the other URLs of a published content.

    Declaration
    public IEnumerable<UrlInfo> GetOtherUrls(int id)
    Parameters
    Type Name Description
    int id

    The published content id.

    Returns
    Type Description
    IEnumerable<UrlInfo>

    The other URLs for the published content.

    Remarks

    Other URLs are those that GetUrl would not return in the current context, but would be valid URLs for the node in other contexts (different domain for current request, umbracoUrlAlias...).

    The results depend on the current URL.

    View Source

    GetOtherUrls(int, Uri)

    Gets the other URLs of a published content.

    Declaration
    public IEnumerable<UrlInfo> GetOtherUrls(int id, Uri current)
    Parameters
    Type Name Description
    int id

    The published content id.

    Uri current

    The current absolute URL.

    Returns
    Type Description
    IEnumerable<UrlInfo>

    The other URLs for the published content.

    Remarks

    Other URLs are those that GetUrl would not return in the current context, but would be valid URLs for the node in other contexts (different domain for current request, umbracoUrlAlias...).

    View Source

    GetUrl(Guid, UrlMode, string?, Uri?)

    Gets the URL of a published content.

    Declaration
    public string GetUrl(Guid id, UrlMode mode = UrlMode.Default, string? culture = null, Uri? current = null)
    Parameters
    Type Name Description
    Guid id

    The published content identifier.

    UrlMode mode

    The URL mode.

    string culture

    A culture.

    Uri current

    The current absolute URL.

    Returns
    Type Description
    string

    The URL for the published content.

    View Source

    GetUrl(int, UrlMode, string?, Uri?)

    Gets the URL of a published content.

    Declaration
    public string GetUrl(int id, UrlMode mode = UrlMode.Default, string? culture = null, Uri? current = null)
    Parameters
    Type Name Description
    int id

    The published content identifier.

    UrlMode mode

    The URL mode.

    string culture

    A culture.

    Uri current

    The current absolute URL.

    Returns
    Type Description
    string

    The URL for the published content.

    View Source

    GetUrl(IPublishedContent?, UrlMode, string?, Uri?)

    Gets the URL of a published content.

    Declaration
    public string GetUrl(IPublishedContent? content, UrlMode mode = UrlMode.Default, string? culture = null, Uri? current = null)
    Parameters
    Type Name Description
    IPublishedContent content

    The published content.

    UrlMode mode

    The URL mode.

    string culture

    A culture.

    Uri current

    The current absolute URL.

    Returns
    Type Description
    string

    The URL for the published content.

    Remarks

    The URL is absolute or relative depending on mode and on current.

    If the published content is multi-lingual, gets the URL for the specified culture or, when no culture is specified, the current culture.

    If the provider is unable to provide a URL, it returns "#".

    View Source

    GetUrlFromRoute(int, string?, string?)

    Declaration
    public string GetUrlFromRoute(int id, string? route, string? culture)
    Parameters
    Type Name Description
    int id
    string route
    string culture
    Returns
    Type Description
    string
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX