I am a little confused on the pro's and con's of each. When is it good to use OpenWeb() vs RootWeb, especially in the context of a using statement.
|
You would never use So, you should never do this:
...and
...but
|
|||||||||||
|
|
If you want to get hold of a subsite using GUID or URL (server-relative or site-relative), OpenWeb() should be used.The SPWeb returned from OpenWeb() should be manually disposed. Also, want to share this for something interesing on OpenWeb() . RootWeb gives you the top most SPWeb associated with SPSite. Although, you can also get it using OpenWeb(), RootWeb is preferred as it does not require explicit disposal of SPWeb object it provides. |
|||
|
|