Oskar Zetterberg
Apr 13, 2011
  7309
(2 votes)

EPiServer CMS6 R2 and broken FriendlyUrlRewriteProvider

Ran into alot of problems yesterday while upgrading our website to the latest EPiServer version, CMS6 R2. The problem: I have made a custom FriendlyUrlRewriteProvider that inherits from EPiServer.Web.FriendlyUrlRewriteProvider that partly stopped working. My custom querystrings was discarded and the link click rendered into a 404 visit.

After alot of head scratching and dll and config checking I digged in to the EPiServer.dll of both the new and old version (CMS 6 and R2) and compared the two classes, method by method. Finally I realized that I needed to add an override for the method TryConvertToInternal with the same functionality as in ConvertToInternal (should have been obvious but I intend to always check the easiest solutions last).

Now the pager and all the other rewrites works as expected. This might not be the correct way to handle this but from what I can tell it works as it should.

Anyone with better solutions are more then welcome to comment on this.

Apr 13, 2011

Comments

Apr 14, 2011 07:25 AM

Hi

Unfortunately we had to make this "semantic breaking change" to the implemenation in Url rewriting to correct a bug regarding language handling.

The suggested way if you have written a custom provider that override ConvertToInternal is to override TryConvertToInternal and move the logic there (just like you did).

Sorry for the inconvenience this have caused...

Ted
Ted Apr 14, 2011 08:18 AM

More people are having this problem, but I think the workaround is acceptable. If you'd talk to Deane Barker (@gadgetopia) you'd see he's had some frustration with FURL rewriters too. :)

smithsson68@gmail.com
smithsson68@gmail.com Apr 14, 2011 10:02 AM

Thanks for sharing Oskar.

Kai de Leeuw
Kai de Leeuw Sep 11, 2012 04:58 PM

I did like this:

public override bool TryConvertToInternal(UrlBuilder url, out CultureInfo preferredCulture, out object internalObject) {
return (bool)typeof(EPiServer.Web.FriendlyUrlRewriteProvider).GetMethod("TryConvertToInternal", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(
this,
new[] { url, 0, preferredCulture = null, internalObject = null });
}

The alternative to doing this was to copy several hundred rows of code just to be able to send LanguageApiMode.Destructive which is required for the code in ConvertToInternalInternal to get called.

Please login to comment.
Latest blogs
Creating an Optimizely CMS Addon - Adding an Editor Interface Gadget

In   Part One   of this series, I covered getting started with creating your own AddOn for Optimizely CMS 12. This covered what I consider to be an...

Mark Stott | Aug 30, 2024

Configure your own Search & Navigation timeouts

The main blog Configure your own Search & Navigation timeouts was posted for years but you need copy the code to your application. We now bring tho...

Manh Nguyen | Aug 30, 2024

Joining the Optimizely MVP Program

Andy Blyth has been honoured as an Optimizely MVP, recognising his contributions to the Optimizely community. Learn how this achievement will enhan...

Andy Blyth | Aug 29, 2024 | Syndicated blog

Welcome 2024 Summer OMVPs

Hello, Optimizely community! We are thrilled to announce and welcome the newest members to the Optimizely Most Valuable Professionals (OMVP) progra...

Patrick Lam | Aug 29, 2024