I provisioned a non publishing custom site. The home page is default.aspx which resides in all files and can be viewed from designer.

I want to get the value of this page contact and last modified date programmatically. Is this possible to do and how?

For a publishing site I know there is contactfieldcontrol to show it.

<sharepointportalwebcontrols:contactfieldcontrol webpart="true" runat="server" __webpartid="{CECDDC12-6DC9-4008-A9ED-26C86BF23015}"
        id="ContactFieldControl1" allowclose="False" allowconnect="False" allowedit="False"
        allowhide="False" allowminimize="False" allowremove="False" allowzonechange="False"
        frametype="None" isdisplayjobtitle="False" isdisplaypicture="True" title="Page Owner"

Using object model you can retrieve this as

SPFile file = web.GetFile("default.aspx");
if(file.Exists) // here, this condition will return always false
    SPListItem item = file.Item;
    if(item != null)
        //item["Created By"]
        //item["Modified By"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy