In this SharePoint customization tutorial, I will explain how to customize access denied page in SharePoint 2013/2016.
After customizing the entire site user wants to redirect all the non-existed users to a different page with custom access denied message. In this article, I would like to walk you through the approach to update/associate a web application with custom access denied page.
The default access denied page for SharePoint 2013 resides at \Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\ AccessDenied.aspx
Customize access denied page in SharePoint 2013/2016
Follow the below steps to customize access denied page in SharePoint 2013/2016.
First, we need to change the default association by following the below steps:
Log on to SharePoint WFE environment with a FARM admin account
Open the windows explorer and navigate to the layouts folder
\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS
Create a new folder called “UserCustomPages” under LAYOUTS folder
Copy the AccessDenied.aspx page to a newly created folder.
Edit the access denied page with the custom message after “ms-accessDenied-reqDialog” tag as shown below.
We can see in the below screen with default AccessDenied mapping and newly user-created access denied page.
Note: You might have noticed that sharepoint associate the AccessDenied page as a relative path. The actual file resided in “\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\UserCustomPages” the relative path for the same is “/_layouts/15/UserCustomPages/UserCustomAccessDenied.aspx”
PowerShell Command set custom access denied page in SharePoint
Below, is the PowerShell script to set a custom access denied page in SharePoint 2013/2016.
Syntax:
Set-SPCustomLayoutsPage -Identity "AccessDenied" -RelativePath "<< Custom relative path >>" -WebApplication "<<Web Application URL >>"
Example:
Set-SPCustomLayoutsPage -Identity "AccessDenied" -RelativePath "/_layouts/15/UserCustomPages/UserCustomAccessDenied.aspx" -WebApplication "http://sharepoint13:12345"
As soon as mapping completed login to SharePoint site with an unauthorized user and it will show the below new user access denied page.
You may like the following SharePoint customization tutorials:
- SharePoint modern list view customization example
- How to Create a Tiles View using SharePoint Online modern list view customization
- SharePoint Online mega menu and Site Customizations
- How to Customize SharePoint Modern list form using JSON
- How to customize a SharePoint List form
- The current page has been customized from its template. Revert to template SharePoint
- The security validation for this page is invalid and might be corrupted error in SharePoint
- How to create a form in SharePoint designer 2013
In this SharePoint tutorial, we learned how to create custom access denied page in SharePoint 2013/2016, and also, we saw how to set custom access denied page in SharePoint 2013/2016 using PowerShell.
I am Krishna.Vandanapu a SharePoint architect working in IT from last 13+ years, I worked in SharePoint 2007, 2010, 2013, 2016 and Office 365. I have extensive hands on experience in customizing SharePoint sites from end to end. Expertise in SharePoint migration tools like Sharegate, Doc Ave and Metalogix. Migrated SharePoint sites from SharePoint 2007 to 2010 and 2010 to 2013 several times seamlessly. Implementing CSOM with Microsoft best practices. Spent quality time in configuring SharePoint application services like User Profile, Search, Managed Meta data services etc. Now exploring SharePoint Framework and SharePoint 2019
[…] Customize access denied page in SharePoint 2013 […]
[…] Customize access denied page in SharePoint 2013 […]