C# – How to display a standard SharePoint “Access Denied” message

cexceptionsharepoint

How can I re-direct the user to the standard SharePoint "access denied" page, similar to the image below?

Currently, I am throwing an UnauthorizedAccessException, but this error message is not as elegant as SP message.

throw new UnauthorizedAccessException("User does not have permission to access this list");

Any help will be highly appreciated.

alt text

Best Answer

You should be able to use SPUtility.HandleAccessDenied to do this. (You can pass in null for the exception parameter if you just want to force the Access Denied page to be displayed, but aren't actually handling an exception.)

Related Topic