Take the SPWeb
object, for instance. I've seen that it can be obtained in any of the following ways:
(1)
SPWeb web = new SPSite(SPContext.Current.Site.ID).OpenWeb();
(2)
SPWeb web = SPContext.Current.Web;
(3)
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = site.OpenWeb())
{
//use the web object here
}
}
Are (1), (2) and (3) identical in they way they work ultimately? If not, which is the better way, and what are the relative differences/advantages/disadvantages? Is there a better approach I've missed?