Custom access denied page is giving 403 error

Nayan NIKUMBH 21 Reputation points
2024-03-05T08:10:41.6766667+00:00

I am developing a custom access denied page for our SharePoint 2019 env. I have taken the default access denied page structure as the template for creating the customized page.

On this page we will display the site owners information and a short message. For this I added couple of labels in the <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> tag. We will fetch the site owners from the site property bag in code behind using SPSecurity.RunWithElevatedPrivileges()

Then we are also mapping the custom page using PS script: Set-SPCustomLayoutsPage -Identity "AccessDenied" -RelativePath ""

When I am trying to open a site am not having access, I am getting 403 error. Same page if I try to access using farm account it displays the owners and custom message properly.

Any pointers where I should look at?

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,287 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,594 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 33,251 Reputation points Microsoft Vendor
    2024-03-06T02:11:59.6133333+00:00

    Hi @Nayan NIKUMBH,

    Are you using SharePoint 2019 modern page? The modern experience doesn't support to insert custom page style by insert css and html file. You will need to use spfx to custom your page. You could refer to following solution

    https://www.sharepointdiary.com/2020/09/sharepoint-online-inject-custom-css-to-modern-sites.html


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.