SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am developing an event receiver, using the ItemUpdating event, and I noticed that the properties parameter has an "OpenWeb" method, with this description:

Retrieves the Web site that is associated with the event that occurred.

while it also has a "Web" property, with this description:

Gets the parent Web site of the list associated with the event that occurred.

what is the difference?

share|improve this question
up vote 10 down vote accepted

The only difference is that properties.Web is cached for the duration of the event (after the first access to it).

So properties.Web is implemented to check if it has a cached SPWeb if so return that if not call properties.OpenWeb() and cache the result.

Neither of them will cause a memory leak as they are created from an SPSite which is disposed at the end of the event

share|improve this answer
so.. i should always use Web, to avoid getting an SPWeb that's already cached? what's the point of having OpenWeb be public then? – Nacht May 29 '12 at 22:53
OpenWeb is mainly for backwards compability. Web didn't exist in WSS 3.0 – Per Jakobsen May 30 '12 at 6:53
Why is OpenWeb not deprecated then? – Nacht Mar 20 '13 at 22:28
SharePoint don't generally deprecate things just because there now is a better option – Per Jakobsen Mar 21 '13 at 7:20

Please check this post

On the same line check

So using SPWeb web = properties.OpenWeb(); is much more efficient.

share|improve this answer
i don't see that conclusion at all! the first link says don't use OpenWeb, as it will leak memory, and the second link says nearly the same thing. Also, neither of those show a time where both OpenWeb() and Web are available from the same object. – Nacht May 29 '12 at 6:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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