My guess is that it has to do with the site configuration. Do you have a site definition in admin mode that matches the host name in your PreviousPageUrl property? Maybe you have correct mapping in staging but not in production?
Is your production site behind a proxy or similar? Some firewalls and proxies does not preserve UrlReferrer
It cant be because I checked to see if the property PreviousPageUrl was empty or not. And it had the previous page URL in the production environment.
If the site definition is correct I'm currently out of ideas. From what I can see the host name matching in UrlResolver is case sensitive. Is your host name mapping lowercase only?
I know now what was causing this! In my site definition we have set it to start with http://www and then the url to the site while the PreviousPageUrl did not contain the www and thats why it could'nt get the contentref from the url.
Thank you Mattias Olsson! I apparently did not pay enough attention when looking at the settings, sorry! :)
Hi all!
I have implemented a method that checks if the previous page is of a specific pagetype. It works perfectly in our stage environment but not in production. I have checked that the property PreviousPageUrl is not an empty string in production. So it can’t be that. It has to be when it tries to get the contentreference for the page where it fails. Have I missed something? The only difference between the two environments that I can think of is that the stage environment is closed. You only access it by login into it.
Br/Isabel
public static string PreviousPageUrl
{
get
{
var urlRef = System.Web.HttpContext.Current.Request.UrlReferrer;
if (urlRef != null)
{
return new UrlBuilder(urlRef.AbsoluteUri).ToString();
}
return string.Empty;
}
}
public static string GetPreviousUrlsPageType()
{
if (string.IsNullOrEmpty(PreviousPageUrl)) return string.Empty;
var contentRef = UrlResolver.Current.Route(new UrlBuilder(PreviousPageUrl));
if (contentRef != null)
{
var page = ContentRepository.Get(contentRef.ContentLink);
if (page is FloorGuideBasePageType)
{
return PageTypes.FloorGuidePage;
}
if (page is ProductAccessoryDetailPageType)
{
return PageTypes.ProductAccessoryDetailPageType;
}
}
return string.Empty;
}