• Core
  • Infrastructure
  • Web
  • Extensions
Search Results for

    Show / Hide Table of Contents
    View Source

    Interface IHostingEnvironment

    Namespace: Umbraco.Cms.Core.Hosting
    Assembly: Umbraco.Core.dll
    Syntax
    public interface IHostingEnvironment

    Properties

    View Source

    ApplicationId

    The unique application ID for this Umbraco website.

    Declaration
    string ApplicationId { get; }
    Property Value
    Type Description
    System.String
    Remarks

    The returned value will be the same consistent value for an Umbraco website on a specific server and will the same between restarts of that Umbraco website/application on that specific server.

    The value of this does not distinguish between unique workers/servers for this Umbraco application. Usage of this must take into account that the same ApplicationId may be returned for the same Umbraco website hosted on different servers.
    Similarly the usage of this must take into account that a different ApplicationId may be returned for the same Umbraco website hosted on different servers.

    This returns a hash of the value of IApplicationDiscriminator.Discriminator (which is most likely just the value of unless an alternative implementation of IApplicationDiscriminator has been registered).
    However during ConfigureServices a temporary instance of IHostingEnvironment is constructed which guarantees that this will be the hash of , so the value may differ depend on when the property is used.

    If you require this value during ConfigureServices it is probably a code smell.

    View Source

    ApplicationMainUrl

    Gets the main application url.

    Declaration
    Uri ApplicationMainUrl { get; }
    Property Value
    Type Description
    Uri
    View Source

    ApplicationPhysicalPath

    Will return the physical path to the root of the application

    Declaration
    string ApplicationPhysicalPath { get; }
    Property Value
    Type Description
    System.String
    View Source

    ApplicationVirtualPath

    The web application's hosted path

    Declaration
    string ApplicationVirtualPath { get; }
    Property Value
    Type Description
    System.String
    Remarks

    In most cases this will return "/" but if the site is hosted in a virtual directory then this will return the virtual directory's path such as "/mysite". This value must begin with a "/" and cannot end with "/".

    View Source

    IsDebugMode

    Declaration
    bool IsDebugMode { get; }
    Property Value
    Type Description
    System.Boolean
    View Source

    IsHosted

    Gets a value indicating whether Umbraco is hosted.

    Declaration
    bool IsHosted { get; }
    Property Value
    Type Description
    System.Boolean
    View Source

    LocalTempPath

    Declaration
    string LocalTempPath { get; }
    Property Value
    Type Description
    System.String
    View Source

    SiteName

    Declaration
    string SiteName { get; }
    Property Value
    Type Description
    System.String

    Methods

    View Source

    EnsureApplicationMainUrl(Nullable<Uri>)

    Ensures that the application know its main Url.

    Declaration
    void EnsureApplicationMainUrl(Uri? currentApplicationUrl)
    Parameters
    Type Name Description
    System.Nullable<Uri> currentApplicationUrl
    View Source

    MapPathContentRoot(String)

    Maps a virtual path to a physical path to the application's root (not always equal to the web root)

    Declaration
    string MapPathContentRoot(string path)
    Parameters
    Type Name Description
    System.String path
    Returns
    Type Description
    System.String
    Remarks

    Depending on the runtime 'web root', this result can vary. For example in Net Framework the web root and the content root are the same, however in netcore the web root is /www therefore this will Map to a physical path within www.

    View Source

    MapPathWebRoot(String)

    Maps a virtual path to a physical path to the application's web root

    Declaration
    string MapPathWebRoot(string path)
    Parameters
    Type Name Description
    System.String path
    Returns
    Type Description
    System.String
    Remarks

    Depending on the runtime 'web root', this result can vary. For example in Net Framework the web root and the content root are the same, however in netcore the web root is /www therefore this will Map to a physical path within www.

    View Source

    ToAbsolute(String)

    Converts a virtual path to an absolute URL path based on the application's web root

    Declaration
    string ToAbsolute(string virtualPath)
    Parameters
    Type Name Description
    System.String virtualPath

    The virtual path. Must start with either ~/ or / else an exception is thrown.

    Returns
    Type Description
    System.String
    Remarks

    This maps the virtual path syntax to the web root. For example when hosting in a virtual directory called "site" and the value "~/pages/test" is passed in, it will map to "/site/pages/test" where "/site" is the value of ApplicationVirtualPath.

    • Improve this Doc
    • View Source
    In This Article
    • Properties
      • ApplicationId
      • ApplicationMainUrl
      • ApplicationPhysicalPath
      • ApplicationVirtualPath
      • IsDebugMode
      • IsHosted
      • LocalTempPath
      • SiteName
    • Methods
      • EnsureApplicationMainUrl(Nullable<Uri>)
      • MapPathContentRoot(String)
      • MapPathWebRoot(String)
      • ToAbsolute(String)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX