In the intranet publishing portal, many times it is wonderful to show the last modified by and last modified date in multi-authoring environment to display the last modified information.
In MOSS 2007 environment, it is ideally done using the custom control or user control hosted in the MasterPage as footer region. Use following code to extract the last modified by and last modified date for the given page in the publishing portal.
using Microsoft.SharePoint;
String PageName = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
using (SPSite RootSite = new SPSite(Page.Request.Url.ToString()))
{
using (SPWeb SiteCollection = RootSite.OpenWeb())
{
string path = RootSite.MakeFullUrl(PageName);
SPFile file = SiteCollection.GetFile(path);
String LastModifiedDate = file.TimeLastModified.ToLongDateString();
String ModifiedBy = file.ModifiedBy.Name.ToString();
lblModifiedBy.Text = ModifiedBy;
lblModifiedDate.Text = LastModifiedDate;
}
}