J'ai une application qui utilise sa propre autorisation pour déterminer si un utilisateur a accès aux pages. Je souhaite afficher une page "Accès refusé" plus convivial dans le cas où l'accès est refusé. Dans le MasterPage ...Erreur de classe UnauthorizedAccessException()
if (!authorize)
{
throw new UnauthorizedAccessException(); //error occurs here, looks like I'm not allowed to use this class
}
Dans le web.config
<customErrors mode="Off" defaultRedirect="~/ErrorPages/ErrorPage.aspx">
<error statusCode="403" redirect="AccessDeniedPage.aspx" />
</customErrors>I get the error below.
Il semble que je reçois l'erreur comme un résultat de juste essayer d'instancier/utiliser la classe UnauthorizedAccessException()
. Je voudrais le faire de cette façon, est-il un moyen d'utiliser cela?
/**************************************************************************************************************************
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 <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
*************************************************************************************************************************/