Easily determine your sites Content Database with a Custom Application Page

During last nights presentation at the Houston’s SharePoint Users Group I demonstrated how to create a simple application page to determine the Content Database of any SharePoint site. While I have posted a link to the presentation in my previous post, I think the Application Page may be very useful to many and have decided to post it here to make it easier to find.

The application page looks as follows and is easily accessible on any site by appending “/_layouts/ShowContentDatabase.aspx” to the URL of the SharePoint site: 

image

Creating the Application Page is very simple.

  1. Go to your LAYOUTS folder, usually located in “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS”
  2. Create a new file named “ShowContentDatabase.aspx”
  3. Add the following code the your file and save your changes.
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0,     Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> <%@ Page Language="C#" MasterPageFile="~/_layouts/application.master"     Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" %> <%@ Import Namespace="Microsoft.SharePoint" %> 

<script runat="server"> protected override void OnLoad(EventArgs e){     SPSecurity.RunWithElevatedPrivileges(delegate()     {      lblContentDatabase.Text = SPContext.Current.Site.ContentDatabase.Name;    }); }

<asp:content id="PageTitle" runat="server" contentplaceholderid="PlaceHolderPageTitle">      Content Database

<asp:content id="PageTitleInTitleArea" runat="server" contentplaceholderid="PlaceHolderPageTitleInTitleArea">      Content Database 

<asp:content id="Main" runat="server" contentplaceholderid="PlaceHolderMain">      Content Database: <asp:Label ID="lblContentDatabase" runat="server" />  

That’s it. The page should be saved to the LAYOUTS folder in each of your Web Front End (WFE) servers.. I would recommend packaging the page in a WSP file and deploying it that way if you have the time.

digg_url = “http://blog.rafelo.com/2009/03/easily-determine-your-sites-content.html”;digg_title = “Easily determine your sites Content Database with a Custom Application Page”;digg_bgcolor = “#FFFFFF”;digg_skin = “compact”;digg_url = undefined;digg_title = undefined;digg_bgcolor = undefined;digg_skin = undefined;
Advertisement

3 Comments on “Easily determine your sites Content Database with a Custom Application Page”

  1. Maarten Ras says:

    Is this only working for 2007?
    I can't get it to work om 2003..

    I get: Could not load type System.Web.UI.WebControls.content from assembly System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

  2. Rafelo says:

    Sorry Maarten, I've never tried it on 2003. I dont believe it will work.

  3. Maarten Ras says:

    Ok, thanks anyway for responding to my question


Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.