I am developing a custom webpart. I have for example this method.
private void DeactivateProvisioningFeature()
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = site.RootWeb)
{
site.AllowUnsafeUpdates = true;
web.AllowUnsafeUpdates = true;
web.Update();
// remove feature if exist
if (site.Features[provisioningFeatureId] != null)
{
site.Features.Remove(provisioningFeatureId);
}
site.AllowUnsafeUpdates = false;
web.AllowUnsafeUpdates = false;
}
}
});
}
What is wrog with this row? Someone told me I do not need to implement the using on the site.RootWeb. Can someone explain please?
using (SPWeb web = site.RootWeb)