Microsoft Knowledge Base Email Alertz

KBAlertz.com: Error message when you edit an .aspx Web page in SharePoint Server 2007: Value does not fall within the expected range

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 953445 - Last Review: November 17, 2008 - Revision: 2.0

Error message when you edit an .aspx Web page in SharePoint Server 2007: "Value does not fall within the expected range"

On This Page

SYMPTOMS

When you edit an .aspx Web page in Microsoft Office SharePoint Server 2007, you receive the following error message:
Value does not fall within the expected range.

CAUSE

Cause 1

This issue occurs if there is a problem with the page layout or if the page layout is corrupted.

Cause 2

This issue occurs if the publishing layout URL of a publishing page contains an incorrect top-level site URL.

Cause 3

This issue occurs if you move a content database or if you run a content deployment job.

RESOLUTION

Resolution for Cause 1

  1. Create a new Web page layout by using the information in the old Web page layout. For example, create a new page layout that is named example_layout_new.aspx by copying the old page layout that is named example_layout.aspx.
  2. Remove HTML content from the new page layout.
  3. Upload the new page layout to the Master Page Gallery. Then, publish the new page layout.
  4. Use the new Page Layout template to create a Web page.
  5. Associate the new Page Layout template with Web pages that already exist.

Resolution for Cause 2

  1. Use Internet Explorer to log on to the Windows SharePoint Services 3.0 site.
  2. Click View All Site Content.
  3. In the View list, click Document Libraries.
  4. Click the document library in which the publishing page resides.
  5. Click Actions, and then click Open with Windows Explorer.
  6. In Windows Explorer view, right-click the publishing page, point to Open with, and then click Notepad.
  7. Note the section of the publishing layout URL for the publishing page that resembles the following:
    <mso:PublishingPageLayout msdt:dt="string">http://incorrect_servername/_catalogs/masterpage/PageLayout.aspx, Article page with image on left</mso:PublishingPageLayout>
  8. Change the incorrect_servername value for the publishing layout URL to point to the correct server.
  9. Save the publishing page back to the Web page list.
  10. Repeat steps 1 through 9 for any other Web page that has this issue.
To resolve this problem, you can also use the code that is listed in the "More Information" section to programmatically update the URL. If you use the code, you do not have to follow steps 1 through 10.

Resolution for Cause 3

To resolve this issue, follow these steps:
  1. Open the affected site in SharePoint Designer 2007.
  2. In SharePoint Designer, point to Reports on the Site menu, point to Problems, and then click Hyperlinks.
  3. In the Reports view, find broken hyperlinks that point to the previous server, right-click the hyperlink, and then click Edit Hyperlink.
  4. Replace the hyperlink with the correct relative path that does not refer to the previous server. For example, change "http://previous_server/_catalogs/masterpage/layout.aspx" to "/_catalogs/masterpage/layout.aspx."
  5. Click Change in all pages, and then click Replace.

    Important Steps 1 through 5 are site specific. These steps must be performed on any other sites or subwebs that are also affected. However, these steps will replace all files in the problem hyperlink.
To resolve this problem, you can also use the code that is listed in the "More Information" section to programmatically update the URL. If you use the code, you do not have to follow steps 1 through 5.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

///
///  This source code is freeware and is provided on an "as is" basis without warranties of any kind, 
///  whether express or implied, including without limitation warranties that the code is free of defect, 
///  fit for a particular purpose or non-infringing.  The entire risk as to the quality and performance of 
///  the code is with the user.
///

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing;

namespace sample_name.SupportTools
{
    class FixPageLayout
    {
        const string USAGE = "Usage: FixPageLayout.exe <url-to-sitecollection>";
        const string MASTER_PAGE_LIB = "_catalogs/masterpage";

        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine(USAGE);
                return;
            }

            string SiteCollectionUrl = args[0];

            if (!Uri.IsWellFormedUriString(SiteCollectionUrl, UriKind.Absolute))
            {
                Console.WriteLine(USAGE);
                return;
            }

            try
            {

                // obtain the site collection
                using (SPSite site = new SPSite(SiteCollectionUrl))
                {

                    // get the servername from RootWeb as it should be
                    using (SPWeb RootWeb = site.RootWeb)
                    {
                        SiteCollectionUrl = RootWeb.Url.ToLower();
                        if (!SiteCollectionUrl.EndsWith(""))
                            SiteCollectionUrl += "http://support.microsoft.com";
                    }

                    // check each site in the site collection
                    foreach (SPWeb web in site.AllWebs)
                    {
                        try
                        {
                            // check if the site is a publishing site
                            if (PublishingWeb.IsPublishingWeb(web))
                            {
                                PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);

                                // check each Publishing page in the current publishing site
                                foreach (PublishingPage page in pubWeb.GetPublishingPages())
                                {
                                    // retrieve the page layout of the publishing page
                                    string pageLayout = page.ListItem.Properties["PublishingPageLayout"] as string;

                                    // check for correct syntax of the page layout URL
                                    if (pageLayout != null)
                                        pageLayout = pageLayout.ToLower();

                                    if (String.IsNullOrEmpty(pageLayout))
                                    {
                                        Console.WriteLine("Error: Page \"{0}\" does not have a Page Layout assigned.\n", page.Uri);
                                    }
                                    else if (!pageLayout.Contains(MASTER_PAGE_LIB))
                                    {
                                        Console.WriteLine("Error: The Page Layout {0} for Page \"{1}\" does not point to the masterpage document library.\n",
                                            pageLayout, page.Uri);
                                    }
                                    else if (!pageLayout.StartsWith(SiteCollectionUrl) && pageLayout.StartsWith("http"))
                                    {
                                        // here we have a page which has a page layout that has a different URL which we have to fix
                                        Console.WriteLine("Page {0} has incorrect PageLayout Url", page.Uri);
                                        Console.WriteLine("Old URL: {0}", pageLayout);
                                        string pageLayoutWithoutPrefix = pageLayout.Substring(pageLayout.IndexOf(MASTER_PAGE_LIB));
                                        string newPageLayout = SiteCollectionUrl + pageLayoutWithoutPrefix;

                                        // perform the update in a try/catch block to cover problems
                                        try
                                        {
                                            int version = page.ListItem.File.MinorVersion;
                                            page.CheckOut();
                                            page.ListItem.Properties["PublishingPageLayout"] = newPageLayout;
                                            page.ListItem.File.Properties["PublishingPageLayout"] = newPageLayout;
                                            page.ListItem.Update();
                                            page.CheckIn("PublishingPageLayout corrected");

                                            //major version means that the item was published. Let's publish it again.
                                            if (version == 0)
                                                page.ListItem.File.Publish("PublishingPageLayout corrected");

                                            Console.WriteLine("Fixed URL: {0}\n", newPageLayout);
                                        }
                                        catch (Exception e)
                                        {
                                            Console.WriteLine("An error occurred while trying to fix the URL to the page layout:\n{0}", e);
                                        }
                                    }
                                }
                            }//if Publishing web
                        }
                        finally
                        {
                            // don't forget to dispose the SPWeb object
                            web.Dispose();
                        }
                    }
                }//using SPSite
            }
            catch (System.IO.FileNotFoundException ex)
            {
                Console.WriteLine("{0}", ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error has occured: {0}", ex.Message);
            }
            
        }
    }
}

APPLIES TO
  • Microsoft Office SharePoint Server 2007
Keywords: 
kbprb kbexpertiseadvanced kbtshoot KB953445
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Michaël Hompus - http://www.winvision.nl Report As Irrelevant  
Written: 9/2/2008 4:25 AM
This error also happens when je create a backup and restore it to a different url while some pages were checked out. The pagelayout then points to the old url. Solution: 1. Download the aspx page 2. Edit the file (correct the path to the pagelayout) 3. Upload the aspx file as a new version 4. Check in

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please