Wednesday, November 28, 2012

Unrecognized Page Types in Sharepoint

Note: I've described the problem at length. If you're just here for a solution feel free to scroll down the page.

The Problem

One of the Sharepoint projects we're currently deploying is for our internal teams to collaborate together. This not only replaces Public Folders, but also other collaboration tools such as custom sites we'd built for our Intranet. Our policy is to give full control to an administrator from within the user group if necessary and possible. This is to alleviate our staff from making endless customizations to these sites and to give the users a sense of empowerment and ownership to aid adoption. So far, it's worked pretty well. I'm writing this because of one of the times it did not, and an unforeseen pitfall of Sharepoint 2010.

If you've been working with Sharepoint for any length of time you're surely familiar with Sharepoint Designer. I won't spend too much time going over that tool except to say that we found it ill suited for any of our purposes very early on in working with the platform. Thus, we didn't think too much about the "Edit in Sharepoint Designer" menu item. That is, until I received this email:

I messed something up…. My entire Health and Safety Statistics page isn’t working… Is there any way to get it back??

The problem was that her page was no longer recognized as a web page. Instead, it was shown as an unknown file type and when you clicked on it in the SitePages collection you were prompted to save the file, rather than shown the content. Even more peculiar, you couldn't rename the file in the web interface such that it regained its extension, nor could you upload a file to overwrite it. Yet, Sharepoint still recognized that the page should contain content and the version history showed previews of that content and allowed for restoration of content versions... but doing that wouldn't restore the file extension and saving the file didn't save the content. Thus, the only way for her to have gotten into this mess, and the only way to fix it without digging into the nasty innards of Sharepoint, was Sharepoint Designer.

It was then that I clicked on the "Edit in Sharepoint Designer" menu item and to my horror I was presented with a very easy to use download page. See, in the past versions we didn't worry about Sharepoint designer because the user would have to go out of their way to get it and our users typically aren't that persistent. Everything changes when the installation process is one of Microsoft's simpler ones. This meant that we not only needed to correct the file name, but also to prevent this in the future by removing Sharepoint Designer from the equation.

The Solution

First, to fix the file we opened the site in Sharepoint Designer, selected the SitePages library, then right clicked on the problem page and selected Rename. At that point it was clear how the problem arose, it renames the whole file - meaning that you can remove, edit, or add the extension. Renaming the file to add ".aspx" fixed the problem.

Next, to remove the "Edit in Sharepoint Designer" menu item we used some CSS. The CSS was added directly to the Master Page file, because we use a custom one and that way the customization is fairly easy to find and change on a site-by-site basis. The process is described here, but this is the specific snippet I put in the head of the Master Page:

<style>
   /* this hides the Edit in Sharepoint Designer menu item. Remove this code to enable that feature. */
   #mp1_0_9, #mp1_0_10 {
      display:none;
   }
</style>

After placing that in the Master Page file, and in the one used by new sites, we've hidden this troublesome option from most users. With any luck, those smart enough to find and use it otherwise will know enough not to mess up their site.

No comments: