sharepointpublishingsharepointfoundation2010webpartpage

Create Sharepoint 2010 Webpart page in C#


I want to programmatically create a Webpart page (.aspx file) for Sharepoint 2010. I already found this code snippet:

public static PublishingPage CreatePage(string fileName, string title)
  {
     PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(Web);
     PageLayout[] layouts = pWeb.GetAvailablePageLayouts();
     PageLayout layout = layouts[0];
     foreach (PageLayout p in layouts)
     {

        if (p.Name.Equals("BlankWebPartPage.aspx"))
        {
           layout = p;
           break;
        }
     }
     try
     {
        PublishingPage newPage = pWeb.GetPublishingPages().Add(fileName, layout);
        newPage.Title = title;
        newPage.Update();
        return newPage;
     }
     catch (Exception)
     {
           return null;
     }
  }

But my problem is SharePoint Foundation Server does not have the Publishing part but I have to run it on a SharePoint Foundation Server. Is it possible to create a Webpart Page without PublishingWeb?

greets


Solution

  • Publishing Infrastructure is one of the features that is only avaialble in SharePoint Server Standard or Enterprise. It is not included in SharePoint Foundation 2010. It wasn't included in Windows SharePoint Servives (WSS) either. Publishing has always required the purchased version of the product.