Tuesday, December 14, 2010

PortalSiteMapProvider was unable to fetch children for node at URL: message: Object reference not set to an instance of an object

I was seeing this error the other day on our test publishing site, and tracked it down to an issue in the web.config file.  Seems like our web.config was using the wrong default provider:

<siteMap defaultProvider="CurrentNavSiteMapProvider" enabled="true">

where it should have been to set to:

<siteMap defaultProvider="CurrentNavigation" enabled="true">

Tuesday, December 7, 2010

EditModePanel Hiding Content in SharePoint 2010

It appears that the functionality of the EditModePanel has changed subtly in SharePoint 2010.  When using PageDisplayMode="Display", like this:

<PublishingWebControls:EditModePanel runat="server" CssClass="editpanel" PageDisplayMode="Display" ID="editmodepanel1">
lorem ipsum dum dolor

in 2007 the content would show to all  users when the publishing page is in display mode.  In 2010, the content will only show to users that have permission to edit the page.  A subtle change to be aware of.

Monday, December 6, 2010

Stapler feature GLOBAL#0 doesn't staple

When adding feature staplers, you can add individual site templates to activate the feature staplee like so:

<FeatureSiteTemplateAssociation Id="c9a041c2-f258-4290-bfa9-96c854a12b24" TemplateName="SPSNEWS#0"/>

where the ID is the Staplee feature ID, and the TemplateName is the [WebTemplate Name]#[Web Template ID].

But when trying to associate ALL site templates, you've got to drop the #[Web Template ID] to get it to work, like this:

<FeatureSiteTemplateAssociation Id="c9a041c2-f258-4290-bfa9-96c854a12b24" TemplateName="GLOBAL"/>

Tuesday, November 2, 2010

PowerShell: Swapping Master Pages of Second Level Site Collections

I kept running into a File Not Found error when using my PowerShell MasterPage swapping scripts in our environment with 50+ site collections.  Turns out a slight modification is needed when working with site collections that live on the second level (ie not the root).  You need to add the Server Relative Url (/sitecoll) to the masterpage path (/_catalogs/masterpage), and you can accomplish that with this:

# First run this to activate the features
$webApp = Get-SPWebApplication -Identity http://webappurl;
$webApp | Get-SPSite -limit all | ForEach-Object {
  $siteurl = $_.Url;
  if ($siteurl -ne "http://webappurl")
  Write-Host $siteurl;
  $result = Enable-SPFeature -Identity "[SiteCollecitonFeatureName]" -Force -Url $siteurl;
  Write-Host $result;

# then run this to swap the masterpages
$webapps = Get-SPWebApplication http://webappurl;
foreach ($site in $webapps.Sites){
    Write-Host $site.url;
    $web = $site.openweb();
    $siteurl = $site.ServerRelativeUrl.TrimEnd('/');
    Write-Host "siteurl:  $siteurl";

    $web.MasterUrl = $siteurl + "/_catalogs/masterpage/[FEATURE FOLDER]/ShinyNew.master";
    $web.CustomMasterUrl = $siteurl + "/_catalogs/masterpage/[FEATURE FOLDER]/ShinyNew.master";


Thursday, October 28, 2010

FileNotFoundException on Custom Page Layout

Out of about 30 page layouts we had for a SharePoint 2007 to 2010 upgrade, one of the page layouts was giving us the following error:

System.IO.FileNotFoundException: File Not Found.
at Microsoft.SharePoint.ApplicationRuntime.SPLocalFileInfo.GetSPLocalFileInfo(String physicalPath, Byte setupPathVersion, Boolean useFallBackLogic)
at Microsoft.SharePoint.ApplicationRuntime.GhostedFileTemplateInfo..ctor(Byte verGhostedPage, String physicalPath)
at Microsoft.SharePoint.ApplicationRuntime.SPDatabaseFile.SetFetchedInformation(Boolean fGhostedPage, Byte verGhostedPage, String pageContent, Guid docId, UInt32 docVersion, String timeLastModified, SPFileLevel level, String masterPageUrl, String customMasterPageUrl, String webUrl, String siteUrl, Guid siteId)
at Microsoft.SharePoint.ApplicationRuntime.SPDatabaseFile..ctor(String virtualPath, Boolean accessDenied, Boolean fGhostedPage, Byte verGhostedPage, Guid docId, UInt32 docVersion, String timeLastModified, SPFileLevel level, String masterPageUrl, String customMasterPageUrl, String webUrl, String siteUrl, Guid siteId, SafeControls safeControls, PageParserSettings pageParserSettings, String pageContent, Object buildDependencySetData, SPWebPartCollectionInitialState initialState)

Any changes we made to the file on the filesystem would not take. Turns out that the page layout was in a weird state -- checked out but not approved (even though it had been previously approved). So we just checked the file out, then back in, and we'd see our new changes that it would read from the SharePoint root directory.

Monday, October 18, 2010

Getting login prompts that won't authenticate, and then a blank page

If you create a new site collection and try hitting your URL but it will not authenticate, and then defaults to a blank white page make sure that you have done the DisableLoopbackCheck in the registry:


Wednesday, September 15, 2010

Can't login to the page after creating a site collection in SharePoint 2010

If you're getting prompted to login to your new site collection, try three times and get thrown back, you're likely going to have to disable the loopback check:

To set the DisableLoopbackCheck registry key, follow these steps:

1. Set the DisableStrictNameChecking registry entry to 1. For more information about how to do this, click the following article number to view the article in the Microsoft Knowledge Base:
281308 Connecting to SMB share on a Windows 2000-based computer or a Windows Server 2003-based computer may not work with an alias name
2. Click Start, click Run, type regedit, and then click OK.
3. In Registry Editor, locate and then click the following registry key:
4. Right-click Lsa, point to New, and then click DWORD Value.
5. Type DisableLoopbackCheck, and then press ENTER.
6. Right-click DisableLoopbackCheck, and then click Modify.
7. In the Value data box, type 1, and then click OK.
8. Quit Registry Editor, and then restart your computer.

Creating a Site Colleciton in SharePoint 2010

After creating a web application, you should next create a site collection:

1) Go to Central Administration -> Application Management and under Site Collection select "Create Site Collections".
2) Give it a title, url and then select the template you'd like to use.
3) Assign the Site Collection Administrators and press okay.

Now your site collection will be created. BUT, since we want to use the host headers, you should go to your C:\windows\system32\drivers\etc\hosts file and add the IP of your machine to that file along with your host header.

Setting up a SharePoint 2010 Web Application

Use the following steps to create a SharePoint 2010 Web Application.

1) Go to Central Administration -> Manage Web Applications.
2) Click on the New button in the ribbon.
3) Create the website (name it something that's relevant, and I recommend appending the port at the end like intranet.com80)
4) Use Port 80
5) Setup a host header with the same as the website (intranet.com).
6) The Path will be automatically filled in with the Host Header and Port (intranet.com:80)
7) Make the Public URL the same as the host header.
8) Name the applicaiton pool the same as the website.
9) Name the Database WSS_Content_Intranet
10) Press okay and voila!

Monday, August 23, 2010

SharePoint 2010 Master Page not getting deployed

If you copy a master page into your 2010 project and it's not showing up in your master page gallery, make sure in the elements.xml file you have the type as "GhostableInLibrary", like such:

<File Path="Intranet2010.master" Url="Intranet2010.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="FALSE" />

Wednesday, August 18, 2010

SharePoint 404 Resource Not Found Error

If you encounter a 404 "Resource Not Found" Error in MOSS 2007 you can View Source from your browser and at the very bottom (in HTML comments), will be the stack trace, which should lead you to the source of your error.