I am pretty sure the reason of the error is because the forms authentication "ticket" has expired. When the users have not done any pagerequest for the last 20 minutes and click on any of GridView links (to edit, delete, sort...) the exception is raised: Sys.WebForms.PageRequestManagerServerErrorException 12031.
The exception is only raised when the GridView is inside an UpdatePanel.
If I delete the UpdatePanel, the application redirects the user to the login page, which should be the expected behaviour.
How can I catch this exception, in order to redirect the user to the login page?
Note: there is already a question about the same error: Sys.WebForms.PageRequestManagerServerErrorException 12031. However, the reason is different since it is related to the size of the objects stored in the ViewState, which is not my case.