Anonymous Access and Publishing Web Pages List

December 22 2011 25 comments

As You know, using PublishingWeb.GetPublishingWeb(web) method causes Access Denied exception for anonymous users. You will also get the same exception if you try to access the PublishingWeb.GetPagesListId(web) or PublishingWeb.GetPagesListName(web) methods.
There are solutions here and here and in many other blogs. These solutions use SPSecurity.RunWithElevatedPrivileges, but that’s not ideal solution for anonymous sites.
So how to get pages list from a web, if you don’t even know if the web is publishing site and you are not able to use PublishingWeb.IsPublishingWeb(web)?
Heres yet another solution. Open the web you want to check if it is a publishing site and try to get the pages list using TryGetList method with the right localized pages list name. You will get the localized name from cmscore.resx file using SPUtility.GetLocalizedString method with resource key “List_Pages_UrlName”.

var pages = web.Lists.TryGetList(SPUtility.GetLocalizedString(
                 string.Format("$Resources:{0}", "List_Pages_UrlName"),
                 "cmscore", web.Language));

if (pages != null)
// do the do

It all gets interesting, if the site is not publishing web, but still contain a list called “Pages”. Then You might want to check another things from returned list, not just if it’s null like in the snippet above.

Jerry Seinfeld: Why not? We’re neighbors. What’s mine is yours.
Cosmo Kramer: [leaning against the door-frame and looking around in wonder] Really?

Popularity: 1% [?]

25 comments to “Anonymous Access and Publishing Web Pages List”

  1. Juha Alhojoki says:

    Thanks, I needed this today and knew where to look for a solution.

  2. This is definitely amazing, You will be a extremely specialized digg. I’ve got become a member of the rss and search in advance for you to trying to find a greater portion of a person’s superb write-up. Also, We’ve provided your web blog during my internet sites

  3. hey says:

    This article offers clear idea in favor of the new users of blogging, that truly how to do blogging.|

  4. Cassandra D. Everhart says:

    Hi buddy i agree with you. nice work!

  5. Great!! thank you for sharing this information.

  6. click here says:

    The problem is that it should work as a “talk to us” page and just for this purpose that I wanted to enable anonymous access, to let a huge number of users access it. I guess the properly solution would be making the entire public site “Online”, so those anonymous users could access this specific page.

  7. sex mitoma says:

    More valuable informations about free sexy chat with hot ladies only at sex mitoma

  8. Visit sextreffen lübeck and chat with hot ladies all night long

  9. When I open your RSS feed it seems to be a bunch of strange characters, is the malfunction on my reader?
    TY, great job! Exactly the stuff I had to know.

  10. Hey cool blog, just wondering what anti-spam software program you use for comments as a result of i get heaps on my blog. Anyway, in my language, there usually are not a lot good source like this.

  11. contact us says:

    This is very brilliant! I can really use this info for my current work. Thanks for sharing this!

  12. all cars says:

    This is just fantastic! I’ll be able to put this information to good use in my current job. Thank you so much for sharing this!

  13. This is awesome and is a big help as well for our projects, thank you for sharing this!

  14. Transexuelle á Rennes is fine web place for casual sexy chat contacts with hot ladies in France

  15. Shemale Linz says:

    Shemale Linz is web platform for casual contacts and sexy chat with hot shemales in EU

  16. Amber Brion says:

    Glad to know this information. Thanks for sharing!

  17. click says:

    This is a great read. Thanks!

  18. Transexuel Sex Bordeaux is the best web place for finding casual contacts in France

  19. Enjoy sexy contacts with fine ladies in EU only at sex winterthur

  20. read more says:

    I appreciate you sharing this post! Thank you very much.

  21. Angel17 says:

    What an excellent post. Keep sharing! New Yukon

  22. Angel17 says:

    Such a nice read. Thanks for sharing! New Yukon

  23. jamesgeller911 says:

    This is nice, thanks for sharing this

Leave a Reply