User Friendly System Maintenance Page - app_offline.htm

app_offline.htm is a special static html page in ASP.NET, which we only copy to IIS root folder when we need to bring down a web site for maintenance. app_offline.htm works for SharePoint too.

1. Create an html page with the name “app_offline.htm”.
2. Make sure file size is more than 512 bytes.
3. Copy to the IIS Root folder.

As long as “app_offline.htm”. file exists in the IIS root, no requests will be processed. Trying to access any page will output app_offline.htm content.

In order to end the maintenance activity, just delete app_offline.htm in IIS root folder.

app_offline.htm file can contain HTML, CSS and JavaScript code but no ASP.NET. Also references to any other files in the directory will not work including images.

Adding Images to app_offline.htm
In order to add an image to the app_offline.htm, use base64 encoding of the image. (Convert any image into a base64 string here)

Note: However I experienced that big images were not rendering. There were no errors but image just not loading.

SharePoint Content Deployment Error - Cannot open file .webpart

I was getting this error “Cannot open file myOldWebpart.webpart” during SharePoint 2010 content deployment job run. The webpart it was given is one of the old webparts I used some time ago but renamed later. So I was wondering whether there are any references left for this old webpart in the content database.

Therefore I used following SQL query to discover any location references for the myOldWebpart.webpart file in content database.

USE  [My-Content-DB]
SELECT DirName, LeafName
FROM [dbo].[AllDocs]
WHERE LeafName = 'myOldWebpart.webpart'

Query result showed that there is a reference in the Web Part Gallery (_catalogs/wp). Since it was the only reference, removing myOldWebpart.webpart file from the webpart gallery fixed my error.

To prevent such issue happening, it is recommended to write code in the FeatureDeactivating event handler to delete all the webpart template files that were created during feature activation.

Here is a sample code to enumerate through the Web Part Gallery looking for the first part of the webpart file name to delete.

/// <summary>
/// Occurs when a Feature is deactivated.
/// </summary>
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    SPSite site = properties.Feature.Parent as SPSite;
    SPWeb web = site.RootWeb;

    List<SPFile> filesToDelete = new List<SPFile>();
    SPList webpartGallery = web.Lists["Web Part Gallery"];

    foreach (SPListItem webpartFile in webpartGallery.Items)
        if (webpartFile.File.Name.Contains("myWebpart"))

    // Delete .webpart files
    foreach (SPFile file in filesToDelete)

However above method will not help if we uninstall the solution package without deactivating the feature. In that case we have to check .webpart file in the Web Part Gallery and have to delete it manually.

IntelliTrace Collector to Locate Issues in SharePoint Sites - Using Correlation ID

IntelliTrace collector can be used to collect diagnostic data in environments such as QA or production where Visual Studio is not present. IntelliTrace collector generates a log file with the extension .iTrace which can be opened in Visual Studio Ultimate edition to start an IntelliTrace debugging session.

To use this feature, we need to do one time setup in the environment that we are going to run it. To start we need file which comes with the Visual Studio 2012 installation. (In my case it was in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\ IntelliTrace\11.0.0\


1. Add the Windows feature “Windows PowerShell Integrated Scripting Environment”

2. Get a copy of file and with Windows PowerShell use the command “expand /f:* .” to extract the cab file.

3. Install the IntelliTrace PowerShell cmdlets with the PowerShell command Import-Module < extracted directory>\ Microsoft.VisualStudio.IntelliTrace.PowerShell.dll.

That’s all about setup.

Collect diagnostic data:

Let’s say there is an error in a custom SharePoint webpart.

1. To start collecting data, open a PowerShell window as administrator and run the command Start-IntelliTraceCollection "<Application Pool name>" <Path to Collection Plan XML in extracted directory> <Full path to Trace log save directory>

2. Confirm with “y” when prompted.

3. Reproduce the problem (refresh the page in above case)

4. Once the exception is thrown, stop the trace collection with PowerShell command Stop-IntelliTraceCollection "<Application Pool name>"

5. Confirm with “y” when prompted.

6. Now check the specified directory to save the iTrace log file. If we repeat this recording, it will generate new files with a unique name each time. Pick the latest file.

7. Copy .iTrace file to an environment with Visual Studio Ultimate edition and double click it to open. Visual Studio will show the IntelliTrace Summary page where we can review events or start debugging with IntelliTrace.

Here we can go to the level where our code is open and exact line where the exception is thrown is highlighted. See more information on debug withIntelliTrace Log in MSDN here.

Note: iTrace log files are pretty big, so remember to stop trace once done otherwise collector might continue collecting data consuming disk space and server resources. Also tips on how to optimize IntelliTrace data collection on production servers arehere