Attempted to perform an unauthorized operation
We are getting this error while updating something in SPWeb.
We are not getting why this error is occurred. We also try with admin login but still error shows that unauthorized operation.
Mean while we found strange solution for the strange problem.
Previously we are using SPWeb object with HTTPContext.Current.Web or properties.ListItem.Web in event handler.
Like
SPWeb objWeb= HTTPContext.Current.Web;
OR
SPWeb objWeb= properties.ListItem.Web;
But updating something regarding this web will cause this error.
So what we found that strange solution.
Do not use SPWeb object this way.
Create new SPWeb object with site.OpenWeb();
Like this
SPSite objSite = new SPSite(SiteUrl));
SPWeb objWeb= objSite. OpenWeb();
It worked for us.
But we don’t know what the reason will cause this problem and what the reason which solve this problem.
No comments:
Post a Comment