I am new to aspx web forms.
I want to catch a specific exception in my web application - Validation of viewstate MAC failed.
I tried this (in Global.asax.cs):
protected void Application_Error(object sender, EventArgs e)
{
HttpException lastErrWrapper = Server.GetLastError() as HttpException;
if ((uint)lastErrWrapper.ErrorCode == 0x80004005)
{
}
}
The problem is that it catches all raw HttpExceptions.
What is the best way to achieve this?
edit:
While checking this problem, I found that the internal exception is this ViewStateException, but it does not have a specific attribute "errorCode"
thank
source
share