Mailing List


Active Directory Products
Object Compare
Permission Compare

IPhone Products
Calls To Calendar
SMS To Gmail
Voicemail To Gmail

How Long For Me
My Music To Me


NerdyHearn - Blog

<< Back To All Blogs

Adding a Custom ASP.NET Page to MOSS/WSS

Sunday, May 3rd, 2009

There are often times that adding a custom ASP.NET page to SharePoint can be quite useful to assist in exporting data, normalizing data, or further enhancing the abilities of SharePoint. This is mostly a trivial process, but setting up the page to work as you need can slow you down a bit at times.

There are also a number of different methods to implementing this ability. An entire ASP.NET application can also be deployed. For the purpose of this article, we are going to focus on a single-file, inline-code C# file that will be added to the layouts folder in SharePoint to extend the ability in all sites.

There is really not much to this process. But you do need to declare things properly in a single file (no code-behind), and register any tag prefixes that you intend to use.

The example I have pasted below is a general layout which you can use while publishing a custom ASP.NET page to SharePoint:

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Assembly Name="Microsoft.SharePoint.ApplicationPages, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Xml.Linq" %>
<script runat=server>
// This code will run at the load-time of the page
protected void Page_Load(object sender, EventArgs e)
// An example below of retrieving the context, checking for validity
// You can then access lists, document libraries, etc from the retrieved context
SPContext ctx = SPContext.Current;

if (ctx != null)
SPWeb web = ctx.Web;
if (web != null)




Related Blogs

Receiving null value when using SPFarm.Local on SharePoint 2010
Resolving "The application failed to initialize properly (0xc000007b)" in MOSS 2007
Deploying Reporting Services WebParts to SharePoint WSS and MOSS
First Version of SharePoint Validator now available on CodePlex
Creating a dynamic SharePoint settings DropDown using a ToolPart


Currently no comments.

Add A Comment



Email Address: (not public, used to send notifications on further comments)


Enter the text above, except for the 1st and last character:

NerdyHearn - Latest tech news relating to C#, ASP.NET, SharePoint, PHP, general development, and more. DocuTerminal - Online Filing Cabinet solution. Scan, search and archive your paper documents. SaveMySerials - Protect yourself from theft, fire, natural disasters and more by recording your serial numbers My Music To Me - Stream your subsonic music collection to your Sonos wireless system TypeCount - Count how often you type across different computers! ServrTrackr - Monitor your SSL certificates, website uptime, and DNS configurations