SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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

To get current SP objects (SPWeb, SPSite, SPList etc), I generally use SPContext.Current. In some situations, SPContext.GetContext is preferred because SPContext.Current have many objects null depending on where the code runs (Webpart page, Edit item form etc).

Are you aware of any guidelines (may be from Microsoft) on the usage SPContext.Current and SPContext.GetContext ?

share|improve this question

Another reason for using the SPContext.GetContext is to set the context of a control to one that is different than the context of the current page. For example, you can set the ItemFieldIterator.ItemContext proprty to get information from a list on different SPWeb object.

myItemFieldIterator.ItemContext = SPContext.GetContext(Context, 0, ListId, oSPWeb);
share|improve this answer

SPContext.GetContext tends to be used if there is no current context (console app? timer job? FeatureUninstalling?), whereby in the case where you do, you would use the obviously named SPContext.Current.

share|improve this answer
Good point.I think what you said is specific to SPContext.GetContext(SPWeb) version, all other overloaded versions require HttpContext...which is not there in Console,timer etc. – Amit Kumawat Dec 4 '11 at 3:14

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.