Try our conversational search powered by Generative AI!

Odd URLs while logged in after upgrading to latest

Vote:
 

We are on CMS 12.  We upgraded all our NuGet packages to the very latest version and after doing this, when we open a page by using the View on website link in the CMS, all the links on the page are generated like this:

https://my-domain.dxcloud.episerver.net/EPiServer/CMS/Content/en-us/fleet-leasing,,2705?epieditmode=true

instead of like this:

https://my-domain.dxcloud.episerver.net/en-us/fleet-leasing

If I open the site in an incognito window where I'm not logged into the CMS, this does not happen.  This only happens if I open a page in the same browser window where I'm also logged into to the CMS.

Is this expected behavior with the latest version of CMS 12?  Is there a setting that controls this?

#298811
Edited, Mar 23, 2023 0:34
Vote:
 

Seems like you are getting or using internal links, typically you should check your code so that the contextMode isn't contextMode.Edit

Care to post a bit of code showing how you output these links in your templates?

#298818
Edited, Mar 23, 2023 8:22
Vote:
 

This is our "GetUrlLink" method:

public string GetUrlLink()
{
    if (PhoneNumber.IsNotNullAndNotWhiteSpace())
    {
        return $"tel:{PhoneNumber}";
    }
    else if (UrlLink != null)
    {
        if (UrlLink.Scheme.Equals("mailto", StringComparison.OrdinalIgnoreCase))
        {
            return UrlLink.OriginalString;
        }
        else
        {
            var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
            var pageRouteHelper = ServiceLocator.Current.GetInstance<IPageRouteHelper>();

            var currentPageUrl = urlResolver.GetUrl(pageRouteHelper.Page.ContentLink);

            if (currentPageUrl == urlResolver.GetUrl(UrlLink.Path) && UrlLink.Fragment.IsNotNullAndNotWhiteSpace() && UrlLink.Fragment.StartsWith("#"))
            {
                return UrlLink.Fragment;
            }

            return urlResolver.GetUrl(UrlLink.OriginalString);
        }
    }

    return string.Empty;
}

I'm thinking the problem is on the 2nd to last return statement:

return urlResolver.GetUrl(UrlLink.OriginalString);

#298826
Mar 23, 2023 11:41
Vote:
 

Hi, I'm not to sure about that. The urllink should most likely look something like this /link/61104228962d4dd2925cb5b12e2373ee.aspx.

I'm sticking with my original guess that you have some issues with your ContextMode. Possibly that you use this method PageEditing.GetEditUrl to resolve the contentLink url. How do you feed the UrlLink property?

#298832
Mar 23, 2023 13:45
Vote:
 

This is my UrlLink property:

[CultureSpecific]
[Display(
    Name = "Link Url",
    GroupName = SystemTabNames.Content,
    Order = 100)]
public virtual EPiServer.Url UrlLink { get; set; }
#298838
Mar 23, 2023 15:41
Vote:
 

Tried your code, added a property just like yours and it works just fine. 

Check your contextmode by running

var contextModeResolver = ServiceLocator.Current.GetInstance<EPiServer.Web.IContextModeResolver>();
// the context mode is available in
var contextMode = contextModeResolver.CurrentMode;

Typically you want ContextMode.Default

#298863
Mar 23, 2023 20:47
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.