Monday, March 17, 2014

Handling the UnauthorizedAccessException in SharePoint Visual Web Part


I came across an issue lately where I had to allow different users to access a web part with each having their own permissions set for a document library.

Some of the users might not have access on the web part or even the library that we have configured with this web part to be shown. So in order to by pass the automatically getting redirected to access denied page we need to run the code in this scope


using (new SPSecurity.SuppressAccessDeniedRedirectInScope())
{
   //Your custom code here
}


That's all that helped me get through this painful situation.

No comments:

Post a Comment