Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8455351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:15:55+00:00 2026-06-10T12:15:55+00:00

I am new to aspx webforms. I want to catch a specific Exception in

  • 0

I am new to aspx webforms.

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)
  {
      // do something
  }         
}

The problem is that it catches all unhandled HttpExceptions.

What is the best way to achieve this ?


edit:

While checking this issue further I found that the inner exception is a ViewStateException, but it doesn’t seem to have a specific “errorCode” attribute

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:15:57+00:00Added an answer on June 10, 2026 at 12:15 pm

    This should do it

    if ((lastErrWrapper != null) && (lastErrWrapper.InnerException != null) 
      && (lastErrWrapper.InnerException is ViewStateException)
    {
    }
    

    The HttpException is designed to make all the HTTP/web related stuff be catchable by one handler, so you need to dig in and look at the original exception. ViewStateException might catch a couple of other View State-related errors, but that’s probably OK.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to
I am new to web development. I have 2 .aspx files and in default
I'm replacing an old ASP.NET webforms app with a new MVC application. However, I
I'm using ReportViewer to create some reports to my web application and I want
I'm trying to implement validation in my ASP.NET Webforms application. Right now, the only
i have created a new web forms application in visual studio 2010 with just
I have an ASP.NET 4 WebForms-based application, and I want to use routing to
If i have an ASP.NET MVC 2 Web Application with the following Views: Main.aspx
I would like to open a new aspx page when i click on a
I am using iframe to open new .aspx page from parent page. child page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.