Question

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

Was it helpful?

Solution

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

IISRESET

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:

    MasterPageFile="~/_layouts/simple.master" 
    

    and not:

    DynamicMasterPageFile="~masterurl/default.master" 
    

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

Beside that it's pretty straightforward.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top