Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

UrlResolver.GetUrl always returns host name url

Vote:
 

Hi,

For some reason, this line of code is always returning the host name url instead of the CMS page url. However, it does work for commerce data. This code is executed in a scheduled job.

url = this.UrlResolver.GetUrl(content.ContentLink, language);

Any ideas how to solve this?

Kind regards

Bart

#206180
Aug 06, 2019 16:25
Vote:
 

Are you sure you have correct domains setup that match where you're browsing from and everything is published? This can happen if you've not, you'll also see that in the CMS the URl when you however over globe in the header is also empty

#206183
Aug 06, 2019 17:56
Vote:
 

Hi Bart,

When you say that GetUrl is returning the hostname url rather than the CMS page URL, do you mean that it's returning http://mysite.tld/mypage/ rather than just /mypage/ or /en/mypage/?

I suspect this issue will be related to the host name setup on your site. GetUrl takes the context in which it's run into account so, if you've got a host set up for mysite.com with the language en and mysite.fr with the language fr and you call GetUrl with an FR page reference from within the EN site, it will return you the full URL including the mysite.fr host. If you make that same call from within the FR site you'd get the URL without the host. This is for good reason in that the path "/", for example, will return different pages depending on which domain you append it to.

Is it an issue that you get the domain returned in the URL?

#206184
Aug 06, 2019 18:16
Vote:
 

Hi,

Currently I've set up 2 host names:

  • localhost:51481
  • https://www.mysite.com

They both have no culture set.

The problem occurs when I run a scheduled job to create an XML sitemap (I'm using Geta.SEO.Sitemaps). The GetUrl method is always returning https://www.mysite.com/language and not the full URL. Maybe this is because it's a scheduled job and there's no HTTP context?

So it's not an issue that the domain is included in the URL but I need the full URL and not only the domain part. 

#206199
Aug 07, 2019 9:03
Vote:
 

We use the Geta sitemap and it creates the sitemap okay but you have to in the configuration add the hostname you're generating and it needs to map to your domain in the site configuration. If you post the screenshot of your geta configuration and the site configuration I'll check it over.

#206202
Aug 07, 2019 9:47
Vote:
 

Unfortunately, I'm not allowed to upload images with my account here so check this: https://gyazo.com/e1409c367421f7e7c44d193fb42a3648

Thanks a lot!

#206204
Aug 07, 2019 9:56
Vote:
 

You should be able to just drag and drop in to the rich text editor here. Can you post your sites configuration as well please.

#206209
Aug 07, 2019 10:01
Vote:
 

I'm not allowed to upload images because I'm not working for a EPiServer partner company. I'm not even allowed to embed hyperlinks that's why you have to copy paste my URL's :/

Here's my site configuration: https://gyazo.com/10b7947ea43bf4b3e97ac8c7005d1ce3

#206210
Aug 07, 2019 10:05
Vote:
 

Ah I didn't realize there was that restriction. I've not used the plugin with multi language before so not 100% sure on this one, I'll message Valdis who works at Geta he might have some ideas.

#206213
Aug 07, 2019 10:12
Vote:
 

Thanks Scott!

I managed to solve it on my own. It turned out we were using an older version of the Geta.SEO.Sitemaps package. And instead of adding it as a NuGet package, we had a copy of the source code in our solution because we had to create a custom ContentFilter and there was no way to override it.

This code line was missing in the SitemapXmlGenerator class and I think that caused the error:

SiteDefinition.Current = SiteSettings;

Anyway, in the latest version of the Geta package, there's an interface IContentFilter so now I added the latest version via NuGet (as it should be instead of having a copy) and created a custom implementation of IContentFilter.

#206215
Aug 07, 2019 14:10
Vote:
 

Ahh that makes sense, I've had that happen before. Glad you got it sorted

#206216
Aug 07, 2019 14:12
Vote:
 

glad Bart, you solved the issue. if you have any further concerns or limitations using Geta.Sitemap package, feel free to file us an issue on GitHub. thx

#206300
Aug 12, 2019 23:50
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.