我有一個應用程序使用自己的授權來確定用戶是否有權訪問頁面。我想在訪問被拒絕的情況下顯示更友好的「訪問被拒絕」頁面。在母版...UnauthorizedAccessException()類錯誤
if (!authorize)
{
throw new UnauthorizedAccessException(); //error occurs here, looks like I'm not allowed to use this class
}
在web.config
<customErrors mode="Off" defaultRedirect="~/ErrorPages/ErrorPage.aspx">
<error statusCode="403" redirect="AccessDeniedPage.aspx" />
</customErrors>I get the error below.
看來,我得到的錯誤一樣的只是試圖實例/使用UnauthorizedAccessException()
類的結果。我想這樣做,有沒有辦法使用它?
/**************************************************************************************************************************
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.
*************************************************************************************************************************/