Pages

Jul 19, 2011

Redirecting to Access Denied Page

If you want to follow the same behavior as SharePoint in your custom web parts, if the user does not meet the security criteria for the current page you should redirect to Access Denied Page.
In order to achieve that you can use HandleAccessDenied method of SPSecurity.
The code bellow shows how to use HandleAccessDenied to redirect to Access Denied Page:
SPUtility.HandleAccessDenied(new Exception("You are not authorized to perform this operation."));

pri

No comments: