I have migrated a site from 2007 to 2010. I then moved the site collection to a place within a subsite using site content and structure.

Everything works fine and I can see everything correctly.

Now I'm creating a timer job and I'm looking for the site collection but it can't find it!

I've used PowerShell and it does return the site, I've looked within the content database and it is also present! I presume that PowerShell is getting it from the content database?

But when doing it through code it doesn't find the site collection!

I'm iterating through webapplication -> then all sites and then all webs, but it doesn't show up.

I've also directly called site using parent id/url and also tried calling the site collection via GUID and url but no luck!

Am I missing something?

How can I update the UI to reflect what is on the content database? Why doesn't SPSite/SPWeb find the site that exists?

1 Answer 1


solved the question that has been haunting me for days!!!

I've been using the SPWebApplication to get the webapp and then I would iterate through the webapp the sites and each sites subsites.

Instead iv called directly the parent sub site within SPSite and looped through its children SPSite.AllWebs and now it returns the correct collection of child sites and subsites :)

Still don't get why it doesn't pick it up from SPWebApplication , but it works and I am happy!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.