Sdl.Web.Mvc/Controllers/PageController.cs
/// <summary>
/// Resolve a item ID into a url and redirect to that URL
/// </summary>
/// <param name="itemId">The ID of the Page to resolve.</param>
/// <param name="localizationId">The context Localization in which to resolve.</param>
/// <param name="defaultItem">Optional ID of a Component to resolve in case the Page cannot be resolved.</param>
/// <param name="defaultPath"></param>
/// <returns>null - response is redirected if the URL can be resolved</returns>
Resolve a item ID into a url and redirect to that URL
Resolve a item ID into a url and redirect to that URL
public virtual ActionResult Resolve(string itemId, int localizationId, string defaultItem = null, string defaultPath = null)
        {
            using (new Tracer(itemId, localizationId, defaultItem, defaultPath))
            {
                string url = null;
                if (!string.IsNullOrEmpty(itemId))
                {
                    url = SiteConfiguration.LinkResolver.ResolveLink($"tcm:{localizationId}-{itemId}-64");
                    if (url == null && defaultItem != null)
                    {
                        if (defaultItem.IsCmIdentifier())
                        {
                            string defaultItemId = defaultItem.Split('-')[1];
                            url = SiteConfiguration.LinkResolver.ResolveLink($"tcm:{localizationId}-{defaultItemId}");
                        }
                        else
                        {
                            url = defaultItem;
                        }
                    }
                }
                if (url == null)
                {
                    url = string.IsNullOrEmpty(defaultPath) ? "/" : defaultPath;
                }
                return Redirect(url);
            }
        }
public virtual ActionResult Resolve ( string itemId , int localizationId , string defaultItem = null , string defaultPath = null ) { using ( new Tracer ( itemId , localizationId , defaultItem , defaultPath ) ) { string url = null ; if ( ! string . IsNullOrEmpty ( itemId ) ) { url = SiteConfiguration . LinkResolver . ResolveLink ( $" tcm: { localizationId } - { itemId } -64 " ) ; if ( url == null && defaultItem != null ) { if ( defaultItem . IsCmIdentifier ( ) ) { string defaultItemId = defaultItem . Split ( ' ' ) [ 1 ] ; url = SiteConfiguration . LinkResolver . ResolveLink ( $" tcm: { localizationId } - { defaultItemId } " ) ; } else { url = defaultItem ; } } } if ( url == null ) { url = string . IsNullOrEmpty ( defaultPath ) ? " " : defaultPath ; } return Redirect ( url ) ; } }
Resolve a item ID into a url and redirect to that URL
Resolve a item ID into a url and redirect to that URL
// we need to resolve this cm uri // must of already been resolved in the model building pipeline
response is redirected if the URL can be resolved
response is redirected if the URL can be resolved
itemId
string
The ID of the Page to resolve.
The ID of the Page to resolve .
localizationId
int
The context Localization in which to resolve.
The context Localization in which to resolve .
defaultItem
string
Optional ID of a Component to resolve in case the Page cannot be resolved.
Optional ID of a Component to resolve in case the Page cannot be resolved .
defaultPath
string
None