UnauthorizedAccessException() class error
<p>I have an application that uses its own authorization to determine if a user has access to pages.  I want to display a more friendly "access denied" page in the event that access denied.  In the MasterPage...</p>

<pre><code>        if (!authorize) 
        { 
            throw new UnauthorizedAccessException(); //error occurs here, looks like I'm not allowed to use this class
        } 
</code></pre>

<p>In the web.config</p>

<pre><code>&lt;customErrors mode="Off" defaultRedirect="~/ErrorPages/ErrorPage.aspx"&gt; 
  &lt;error statusCode="403" redirect="AccessDeniedPage.aspx" /&gt; 
&lt;/customErrors&gt;I get the error below.  
</code></pre>

<p>It appears that I get the error just as a result of just trying to instantiate/use the <code>UnauthorizedAccessException()</code> class. I'd like to do it this way, is there a way to use this?</p>

<pre><code> /**************************************************************************************************************************
Attempted to perform an unauthorized operation. 

Exception Details: System.UnauthorizedAccessException: Attempted to perform an unauthorized operation. 

ASP.NET is not authorized to access the requested resource. Consider granting access  rights to the resource to the ASP.NET request identity. ASP.NET has a base process  identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and  the configured application pool identity on IIS 7.5) that is used if the application is  not impersonating. If the application is impersonating via &lt;identity impersonate="true"/&gt;, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated  request user. 
*************************************************************************************************************************/
</code></pre>
