The
PublishingWeb class provides publishing behavior for an
SPWeb instance that supports publishing. This class cannot be inherited.
Namespace: Microsoft.SharePoint.Publishing
Assembly: Microsoft.SharePoint.Publishing (in microsoft.sharepoint.publishing.dll)

Syntax
Visual Basic (Declaration)
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
Public NotInheritable Class PublishingWeb
Dim instance As PublishingWeb
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)]
public sealed class PublishingWeb

Remarks
The PublishingWeb class provides publishing specific behavior for an SPWeb that supports publishing, including access to child PublishingPage and PublishingWeb instances; variations support; navigation settings; PageLayout and Web template restrictions; and Welcome page settings. This class wraps an SPWeb instance that has the publishing feature activated.
This class can be instantiated by using the static GetPublishingWeb method or by retrieving it from a PublishingWebCollection collection.
The PublishingWeb class wraps the SPWeb class. It also directly exposes the underlying SPWeb through the Web property so that additional SPWeb functionality can be easily accessed.

Example
[c#]
// Access the Pages list information without creating a PublishingWeb
// object.
using (SPSite site = new SPSite("http://myteam/team/"))
{
using (SPWeb web = site.OpenWeb())
{
if (PublishingWeb.IsPublishingWeb(web))
{
// Get the Id for the Pages list if we
// know that Web is a PublishingWeb.
Guid pagesListId = PublishingWeb.GetPagesListId(web);
// Get the list by way of the Id.
SPList pagesList = web.Lists[pagesListId];
// Get the Pages list URL. Note:
// PublishingWeb.GetPagesListName(web)
// is equivalent to pagesList.RootFolder.Url.
string pagesListUrl = PublishingWeb.GetPagesListName(web);
}
else
{
// If the SPWeb is not a PublishingWeb,
// then GetPagesListName returns the URL
// that would be used by the Pages list
// if the Publishing feature were to be
// activated.
string pagesListName = PublishingWeb.GetPagesListName(web);
}
}
}
// You can also create a PublishingWeb and access
// the properties from it.
using (SPSite site = new SPSite("http://myteam/"))
{
using (SPWeb web = site.OpenWeb())
{
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
// Get the Id for the Pages list.
Guid pagesListId = publishingWeb.PagesListId;
SPList pagesList = publishingWeb.PagesList;
// The PublishingWeb.PagesListName is equivalent
// to PublishingWeb.PagesList.RootFolder.Url.
string pagesListUrl = publishingWeb.PagesListName;
}
}

Inheritance Hierarchy

Thread Safety
Any public static (
Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also