I've used the following powershell script to change the default access denied page for my web Application:

Set-SPCustomLayoutsPage -Identity "AccessDenied" -RelativePath "/_layouts/Custom/AccessDenied.aspx" -WebApplication "MyWebApp"

My Web Server (wfe) is behind an UAG server and I receive the following error: This error (HTTP 403 Forbidden) means that Internet Explorer was able to connect to the website, but it does not have permission to view the webpage.

(My custom AccessDenied.aspx page is based on a custom application page OOTB VS2010)

Update: When I copy paste the OOTB AccessDenied.aspx page and make a small change, this error does not come up and the page is displayed correctly... It looks like an issue with the master page it's using, when using the simple.master I have no problems, when you try to apply a custom or default the error pops up

  • Are you redirected your custom Access Denied page (based on the URL)? Nov 21, 2011 at 17:02
  • I don't understand your question so well. I didn't configure any redirection, just applied the above PS statement
    – Wim Hill
    Nov 21, 2011 at 17:16
  • When you do not have permissions, SharePoint will redirect you to the access denied page. Does it redirect you to your configured page (it does not matter if you get the error)? Nov 21, 2011 at 17:55
  • do you have any code written in there? Nov 21, 2011 at 20:18
  • There's no custom code (behind) in the page. I'm redirected to my configured page
    – Wim Hill
    Nov 22, 2011 at 7:21

2 Answers 2


I had the same behavior on my site. (SP2010 Enterprise using Windows auth (NTLM)).

The way I solved it is to create a _layouts deployment project to deploy my custom401.aspx (will come back to it).

Updated my webapplication with:

$urlWebApplication = "http://myApp"
$pathPage401 = "/_layouts/myproject/custom401.aspx"

#Change 401 page for webapp
Set-SPCustomLayoutsPage -Identity AccessDenied -WebApplication $urlWebApplication -RelativePath $pathPage401 

#Check if changed

Get-SPCustomLayoutsPage -WebApplication $urlWebApplication


For the aspx page, there are 2 important steps.:

  1. Make sure your page inherits UnsecuredLayoutsPageBase and not the default.

  2. Make sure the masterpage is referenced using:


    and not:


    as it will try to access resources on the site which will trigger the 403.

Beside that it's pretty straightforward.


By default VS.NET 2010 uses LayoutsPageBase as your base class. You need to modify it to UnsecuredLayoutsPageBase so that your custom access denied page is derived from UnsecuredLayoutsPageBase.

  • Unfortunatly this didn't resolve the problem!
    – Wim Hill
    Nov 21, 2011 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.