Hi All,
If you want to redirect unauthorized user(s) to error page or access denied page, where they are going to deal with the page, without having proper permission. Instead of building new page(s), we can simply redirect them to access denied page.
you can use SPUtility.HandleAccessDenied() function.
Here is an example:
SPUtility.HandleAccessDenied(new Exception(“You don’t have access rights to see this content”));
Hope this simple tips helps you.
If you want to redirect unauthorized user(s) to error page or access denied page, where they are going to deal with the page, without having proper permission. Instead of building new page(s), we can simply redirect them to access denied page.
you can use SPUtility.HandleAccessDenied() function.
Here is an example:
SPUtility.HandleAccessDenied(new Exception(“You don’t have access rights to see this content”));
Hope this simple tips helps you.
Very usefull tip.
ReplyDeleteBut, I am not getting the custom error message passed with Exception constructor.
Any suggestion please