Kristoffer Petersson
Oct 30, 2009
  6827
(1 votes)

Friendly Url and mobile phones

The EPiServerFriendlyUrlRewriteProvider in EPiServer CMS 5.2 SP2 can cause navigational problems for visitors using mobile phones. I have noticed that the browser in some Ericsson mobile phones does not handle friendly URL’s very well.

Recently this became a problem for a site I have been working on. Menus and all navigation worked well in standard web browsers, however navigating the site from my Ericsson mobile phone was simply not possible. EPiServer lost track of the current page and all menus were loaded from the root page.

One obvious solution was to use the EPiServerNullUrlRewriteProvider and go back to using the old style URL’s (somefolder/somepage.aspx?id=12345). This was not possible for the site I was working on.

My solution was to stop the rewriting of URL’s pointing to pages design for mobile phones and handle the loading of these pages in code.
The first step is to stop rewriting of specific URL’s, in my case all paths containing “/mobile”. This can bee done in Global.asax.

In Application_Start add the following:

EPiServer.Web.UrlRewriteModule.HttpRewriteInit += UrlRewriteModule_HttpRewriteInit;

Then add the following to Global.asax

private void UrlRewriteModule_HttpRewriteInit(object sender, UrlRewriteEventArgs e) { UrlRewriteModuleBase module = sender as UrlRewriteModuleBase; if (module != null) { module.HtmlAddingRewriteToExternalFilter += module_HtmlAddingRewriteToExternalFilter; } } private void module_HtmlAddingRewriteToExternalFilter(object sender, UrlRewriteEventArgs e) { string path = e.Url.Path.ToLowerInvariant(); e.Cancel = path.Contains("/mobil"); }

Now rewriting will be cancelled for URL’s containing “/mobile”. However this alone did not solve the problem. EPiServer still couldn’t load the correct page. The second step is to handle loading of pages.

I retrieve the PageData object for the desired page using the ID-parameter from the raw URL.

PageData pd = null; System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(url, "(\\?id=)[0-9]*"); if (!String.IsNullOrEmpty(m.Value) && int.TryParse(m.Value.Remove(0, 4), out id)) { pd = DataFactory.Instance.GetPage(new PageReference(id)); } return pd;

With use of the PageData object I can load the correct page, access properties and initiate menus. Problem solved for now. I am looking for a better solution, do you have one?

Oct 30, 2009

Comments

Sep 21, 2010 10:32 AM

Do you know why it does it not work well with the phone? Are the Friendly URL:s to long?

Or do you have the old style links with ID parameter that you want to use? If you want to make id to work you have to take care of this in ConvertExternalToInternal instead since the id and epslanguage parameter is is deleted from the query string by FURL.

Turning off outgoing FURL filter is not recommended and it has a lot of other side effects.
/ Fredrik Haglund (INEXOR AB)

Sep 21, 2010 10:32 AM

No I do not know why, nor does EPiServer. The URL's are not to long, they can be even longer with old style links. The problem was reported as a bug in a previous version of EPiServer CMS5 and has now been fixed. This seems to be a new bug or a local fault in the site. I tried using ConvertExternalToInternal but could not make it work for me. At least this solution works and it is contained to a small portion of the site.
Thank you for your comment

/ Kristoffer

MuraliKrishna@websynergies.biz
MuraliKrishna@websynergies.biz Jul 13, 2011 06:52 AM

Hi,
I am new to Mobile version.Can any one suggest me how to develop a simple page to view in mobiles?...........

MuraliKrishna@websynergies.biz
MuraliKrishna@websynergies.biz Jul 18, 2011 09:36 AM

OK.My problem is fixed.i used EPIModule and Mobile Pack to view the pages of mobile version in episerver cms......still i hv to view it in IPhone.......

Please login to comment.
Latest blogs
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024