Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a standard SharePoint "Access Denied" message

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

like image 219
Henrique Zacchi Avatar asked Dec 23 '22 12:12

Henrique Zacchi


1 Answers

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.)

like image 91
DylanW Avatar answered Feb 01 '23 23:02

DylanW