Have you ever tried to debug the inline code of custom layout pages of a SharePoint site ?. I have tried once and I couldn't able to debug the inline code by just opening it in VS.NET IDE and attaching the w3wp processor to the debugger. Initially I couldn't figure out why it is not able to debug the inline code. After that I have checked debug mode in the compilation tag of web.config, then I found that it was false by default as like this <compilation batch="false" debug="false">
I had just made a change in that web.config file by making the debug="true" and I was able to debug the inline code.
<compilation batch="false" debug="true">
Whenever we create a custom layout page, we have to keep those aspx pages in the location C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS, now any SharePoint site in that particular SharePoint server can access that page by the following URL. http://<sitename>/_layouts/mycustom.aspx. If we create a custom layout page in the Layouts folder we can't use a separate code behind file as like what we normally use with aspx pages in a asp.net application (though we can create an asp.net application with aspx pages and code behind file and keep it in the layouts folder.).
Now consider we have created a custom layout page with name ‘mycustom.aspx’ and the following inline code.
<%@ Assembly Name="Microsoft.SharePoint, Version=220.127.116.11, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Assembly Name="System.Web, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" %>
<%@ Assembly Name="System.Data, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b77a5c561934e089" %>
<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master" Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
protected override void OnLoad(EventArgs e)
Response.Write(“Hi, welcome to my custom layout page”);
catch (Exception ex)
After that, we are placing it in to the Layouts folder C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS, now all SharePoint sites in that SharePoint server can access that page as like this, http://<sitename>/_layouts/mycustom.aspx
Now, If you want to debug the inline code of that layout page, please follow the below steps.
PingBack from http://www.virtual-generations.com/2008/03/25/sharepoint-2007-link-love-03-25-2008-part-deux/
great post! this was exactly what i needed.
Thanks Shereen. Good to hear that :)