Custom 403 Error Handing for SharePoint

Yesterday I was working on the custom error handing for the SharePoint. They wanted to provide the consistent look and feel for all errors that you can expect – from 301 to 500. It’s quite simple task and what you just need is to turn off custom errors in web.config and set customized error pages in IIS.

The reason we customized error pages via IIS is that we didn’t want to mess up with customization of OOTB pages, and our pages have several pictures. Rendering pictures for “unauthorized” and “forbidden” errors under SharePoint in problematic. That’s why we just redirect user to another site with custom error pages.

The only issue we experienced is customizing 403 page, when SharePoint handled it gracefully redirecting us to _layoutsAccessDenied.aspx page. To avoid such behavior I end up with URL parsing and status code analysis via custom HTTPModule.

I published this solution as SharePoint feature on the CodePlex site


  1. Kundan Ghimire Said,

    January 21, 2010@ 3:10 pm      Reply

    Thanks for the great solution. Is it possible to use this with top level site instead of web app?


  2. Michael Said,

    January 22, 2010@ 12:31 am      Reply

    You can download the source code and modify Custom403PageModule.cs class to check the url.

RSS feed for comments on this post · TrackBack URI

Leave a Comment