App_Offline.htm and working around the “IE Friendly Errors” feature

I posted the slides+demos from my ASP.NET 2.0 Tips and Tricks talk online last week from the ASP.NET Connections Conference in Orlando. One of the new features I talked about was the "App_Offline.htm" feature in ASP.NET 2.0, which provides a super convenient way to bring down an ASP.NET application while you make changes to it (for example: updating a lot of content or making big changes to the site where you want to ensure that no users are accessing the application until all changes are done).

The way app_offline.htm works is that you place this file in the root of the application. When ASP.NET sees it, it will shut-down the app-domain for the application (and not restart it for requests) and instead send back the contents of the app_offline.htm file in response to all new dynamic requests for the application. When you are done updating the site, just delete the file and it will come back online.

One thing I pointed out in the talk that you want to keep an eye on is a feature of IE6 called "Show Friendly Http Errors". This can be configured in the Tools->Internet Options->Advanced tab within IE, and is on by default with IE6. When this is on, and a server returns a non HTTP-200 status code with less than 512 bytes of content, IE will not show the returned HTML and instead substitutes its own generic status code message (which personally I don't think is super friendly ).

So if you use the app_offline.htm feature, you should make sure you have at least 512 bytes of content within it to make sure that your HTML (instead of IE's friendly status message) shows up to your users. If you don't want to have a lot of text show-up on the page, one trick you can use is to just add an html client-side comment with some bogus content to push it over 512 bytes.

Adjust SharePoint Log Settings

Is there any out of the box way to reduce the amount of logging SharePoint does? This would help us in our disk space usage.

Yes, you can. In the central administration web site go to Operations -> Diagnostic Logging. You can change the level of logging or turn if off altogether.

Add left hand navigation to Sharepoint

Site Actions, Site Settings, Modify Navigation

Add Heading
URL: /PH/SwineFlue/Forms/AllItems.aspx

Default Site Navigation Settings are:
Show subsites
Show pages
Sort manually, uncheck Sort pages automatically
Display the same navigation items as parent site
Display only the navigation items below the current site

Export / import sub-site

Date: Monday, May 04, 2009
Problem:  Public Health site became out of synch on ships due to creation of new document library
Solution: Use stsadm to export sub-site, copy to ships, and import sub-site

STEP 1: Export sub-site Reference:\\halefleet01.flagship.hal.com\d$\Exports\PH\PHExport.bat

c:
cd "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN"
stsadm.exe -o export -url "http://efleet2/PH" -filename "D:\Exports\folder\PH" -includeusersecurity -versions 4 -cabsize 15

STEP 2: Copy export files and import batch to ships, refer to STEP 4

STEP 3:
Sign onto ship, delete site

Site Actions, Site Settings, Modify All Site Settings
"Site Administration", "Delete this site"

STEP 4: Import sub-site Reference:\\halefleet01.flagship.hal.com\d$\Exports\PH\PHImport.bat

c:
cd "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN"
stsadm.exe -o import -url "http://staging/PH" -filename "D:\Exports\PH\PH.cmp" -includeusersecurity -updateversions 2

STEP 5: Replication Check, if necessary

Run replication, it should work with new structure

List does not exist error message

Reference Article

I ran into an issue today where users could not access as SharePoint 2007 Publishing Site Page. The error message was:List does not exist.

The page you selected contains a list that does not exist. It may have been deleted by another user. Troubleshoot issues with Windows SharePoint Services. I had no problem viewing my site and couldn't figure out what was wrong. I then looked at the URL for the page which was:
http://[sharepoint-site-URL]/_layouts/AccessDenied.aspx?Source=[SharePoint-site-URL]&Type=list&name=%7B2007BFAB%2D9CC4%2D41DA%2D8ED0%2D7E4C5BDAE90C%7D

The key here was the AccessDenied pages and the name query string value:
7B2007BFAB%2D9CC4%2D41DA%2D8ED0%2D7E4C5BDAE90C%7D

After decoding the html encoded characters out I got a GUID of:
{2007BFAB-9CC4-41DA-8ED0-7E4C5BDAE90C}

If you look at the name, it is actually the id of "list item" that the user has been denied access from viewing. I then went to central administration to get the name of the content database of the site I was working on, and then went to SQL Server Management Studio and expanded my content database to dbo.AllLists. I ran a query against my content database for the list that users have been denied access to.
select * from dbo.alllists
where tp_id='{2007BFAB-9CC4-41DA-8ED0-7E4C5BDAE90C}'

I received one result with a tp_Title of "Master Page Gallery." That was all I needed. I then went to my page and looked at the template it was using. It was using a custom page layout I created. I proceeded to look at my Master Page Gallery and saw that the page layout it was using was never checked in and was in a ‘pending’ status.

Not the best error message, but the lesson here is that users cannot access pages using page layouts that have never been checked it. Makes sense, but a more meaninful error message would have been nice.

Stsadm commands for backup, restore, and locking site

Use stsadm to lock a SharePoint site prior to backup.
Refer: msft articleExamples

A common situation where the getsitelock and setsitelock operations are useful is when a site is backed up. Typically, before you back up a site collection, the site should be locked and no users should have access to it.

Lock Site
To determine the lock status of the site, you can use the following getsitelock syntax:
stsadm -o getsitelock -url http://server_name

Once the lock status of the site collection is determined, you can use the noaccess parameter of the setsitelock operation to lock out all users to the site:

stsadm -o setsitelock -url http://server_name -lock noaccess

You can also use the following command to put the site into "read only" access:

stsadm -o setsitelock -url http://server_name -lock readonly

Backup Site
You can use the Backup operation to create a backup of the site collection:
stsadm -o backup -url http://server_name -filename "filename.bak" -overwrite

After the site has been backed up, you can use the none parameter of the setsitelock operation to remove all locks to the site:

stsadm -o setsitelock -url http://server_name -lock none

Restore Site
stsadm -o restore -url http://w2k3vpc -filename filename.bak -overwrite

Delete Site
stsadm -o deletesite -url http://w2k3vpc

Manage Server Farm with Scripts
sharepoint-buildout-farm-scripts

Enumeration / Details
"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\STSADM.EXE" -o enumsubwebs -url http://efleet

"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\STSADM.EXE" -o enumsites -url http://efleet