Wednesday, May 4, 2011

EPiServerException: PageReference string cannot be null/empty

Nansen is currently working on a number of websites based on EPiServer CMS 6 R2 and we've encountered an editorial issue when saving and resizing images in the built in Image Editor.

Apparently there's a bug in CMS 6 R2 that handles the parent/parentId parameter in the Image Editor dialog incorrectly.

The error you get is:

"EPiServerException: PageReference string cannot be null/empty"


Steps to solve it:

1. Open the file:

C:\Program Files (x86)\EPiServer\CMS\6.1.379.0\Application\UI\CMS\Edit\ImageEditor\ImageEditor.aspx

2. Locate line 459:

var parent = "<%= Server.HtmlEncode(Request.QueryString["parentId"]) %>";

3. Add a fallback for handling "parent" as a parameter.

var parent = "<%= Server.HtmlEncode(Request.QueryString["parentId"]) %>";

// CMS6 R2 quick fix by Nansen
if(parent == "") {
parent = "<%= Server.HtmlEncode(Request.QueryString["parent"]) %>";
}


4 comments :

  1. Thanks a lot for this post. Did you report the bug to EPiServer?

    ReplyDelete
  2. If you use TinyMCE editor, it won't throw this error. We haven't had that fix for old version legacy editor

    Bug #71073: "EPiServerException: PageReference string cannot be null/empty" when using LegacyPropertyXhtmlStringControl in CMS6R2 editor instead of TinyMCE to edit and resize images

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. In case this quick fix doesn't work, here's another solution:

    You can either enable ViewState in web.config (I wouldn't suggest this) or just for the FileSaveAs.aspx.

    This file is probably at: C:\Program Files (x86)\EPiServer\CMS\6.1.379.0\Application\UI\CMS\Edit\ImageEditor\FileSaveAs.aspx, or wherever you have your EPiServer application files installed.

    Then change enableViewState to true on your FileSaveAs.aspx, so it looks like this:
    <%@ Page Language="C#" AutoEventWireup="false" CodeBehind="FileSaveAs.aspx.cs" Inherits="EPiServer.UI.Edit.ImageEditor.FileSaveAs" MasterPageFile="../../MasterPages/EPiServerUI.Master" enableViewState="true" %>

    Make sure to remove the above Nansen Quickfix if you have it there. You may have to restart IIS.

    EPiServer support actually worked on this one with me, so passing the word on here.

    ReplyDelete