Alternative for PublishingWeb.IsPublishingWeb

December 19 2012 127 comments

Just today I wondered why something was not working with a specific custom code and was able to track the problem down by debugging to using PublishingWeb.IsPublishingWeb -method to a web in another site collection with read-permissions. The error message was somewhat puzzling, something like:

0×80070002

at Microsoft.SharePoint.Library.SPRequestInternalClass.GetWebUrl(Guid gWebId, String bstrSiteUrl)…..

Then I remembered that my colleaque Tomi Tavela had resolved figuring out whether the SPWeb object is a publishing web or not in an anonymous scenario in this post Anonymous Access and Publishing Web Pages List.

So what I did following Tomi’s approach was to implement an alternative for the awkwardly behaving PublishingWeb.IsPublishingWeb -method by creating a method which checks if the site (SPWeb) has got a Pages-library.

public static bool IsPublishingWeb(SPWeb web)
{
    if (web == null || !web.Exists) return false;
    return web.Lists.TryGetList(SPUtility.GetLocalizedString
           ("$Resources:List_Pages_UrlName", "cmscore", web.Language))
           != null;
}

Popularity: 1% [?]

127 comments to “Alternative for PublishingWeb.IsPublishingWeb”

  1. Obit Buzz says:

    Thank you for sharing this valuable information
    Obit Buzz

  2. Nicolo says:

    Thanks for sharing this alternative to Abilene Drywall Contractors. We might use it in the near future!

  3. Thank you for sharing this valuable information
    Grace Charis Age

  4. Obitt Buzz says:

    To view more related posts, click this link. Dave Register Height

  5. To view more related posts, click this link. Derek Lipp Net Worth

  6. Click this link to see more posts that are similar. https://justpaste.it/b15re

  7. Click this link to see more posts that are similar. https://smithfieldins.com/

  8. Sol Week says:

    Thank you for this wonderful blog
    Thomas Sullivan Roadkill Story

  9. sarahgonigal says:

    To View Further Noteworthy Articles. Billie Early Bio

  10. ken hensley says:

    View Additional Significant Articles. Jack Doherty Net Worth

Leave a Reply