In case if you are interested in creating your own custom error page and custom access denied page instead of the out of the box MOSS / Sharepoint error page (generally the requirements in Publishing internet site). You can use the following HTTPModule