2012-08-04 2 views

ответ

1

Вы можете использовать несколько обработчиков исключений

 try 
     { 
      // code here 
     } 
     catch (UnauthorizedAccessException) 
     { 
      Response.Redirect(errorPageUrl, false); 
     } 
     catch (Exception) 
     { 
      Response.Redirect(loginPageUrl, false); 
     } 
+0

Я могу определенно сказать, что это суббота тот факт, что я не сделал даже подумайте о том, чтобы сделать перенаправление самостоятельно. : - \ –

3

Попробуйте установить что-то вроде этого в Global.asax.cs

protected void Application_Error(object sender, EventArgs e) 
{ 
    // excpt is the exception thrown 
    // The exception that really happened is retrieved through the GetBaseException() method 
    // because the exception returned by the GetLastError() is a HttpException 
    Exception excpt = Server.GetLastError().GetBaseException(); 

     if(excpt is UnauthorizedAccessException) 
     { 
     // redirect here 
     } 

} 
Смежные вопросы