System.Web.HttpException: The viewstate is invalid for this page and might be corrupted.

Posted on 2005-04-27
Last Modified: 2010-08-05

I am getting the following error "The viewstate is invalid for this page and might be corrupted"  in opening a page. what should be done to resolve this problem.

The following is the compiled output of the error file.

Thanks in advance

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The viewstate is invalid for this page and might be corrupted.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
Stack Trace:
[HttpException (0x80004005): The viewstate is invalid for this page and might be corrupted.]
   System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +150
   System.Web.UI.Page.LoadPageViewState() +18
   System.Web.UI.Page.ProcessRequestMain() +423
Question by:dnlakhani
    LVL 9

    Expert Comment

    This happens when you first navigate to a page?  Or after a postback?  I assume you've tried closing and reopening the browser window (as well as rebooting the machine).

    Take a look at this Microsoft KB article:;en-us;831150

    It might help you retrieve a more thorough explanation of the error.  If you think you know what code might be causing the problem, please post it as it will help the troubleshooting process.
    LVL 1

    Author Comment


    I have referred to this site already but didn't find anything interesting out there...!

    Well I think U will be able to understand this better if I explain u the  situation.
    I have a  form which has three frames in it. Now our discussion is going to be regarding the left frame and the central frame.

    Lets say the left frame has the form tsdocumentsearch.aspx in it. This form has an image from where another aspx form called searchresults.aspx form is being called so this has to open in the centre frame.

    This is the code for the tsdocumentsearch.aspx
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="Tsdocumentsearch.aspx.vb" Inherits="IRDtsearchDevelopmentnew.Tsdocumentsearch"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <SCRIPT language =javascript>
    function checkingpeop()
    document.Form1.action = "SearchResults.aspx?";      
    return true;
                <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
                <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
                <meta name="vs_defaultClientScript" content="JavaScript">
                <meta name="vs_targetSchema" content="">
                <link href="ir.css" rel="stylesheet" type="text/css">
                <link href="scroll.css" rel="stylesheet" type="text/css">
                <base target = main>
          <body bgColor="#cedbef" MS_POSITIONING="GridLayout">
                <form id="Form1" method="post" runat="server">
                      <font color="#000000">
                            <asp:label Font-Bold="True" id="Label1" runat="server" style="Z-INDEX: 101; LEFT: 11px; POSITION: absolute; TOP: 49px" class="FontStyle">
            Search Request</asp:label>
                            <asp:textbox class="TitleBtn" id="SearchRequest" style="Z-INDEX: 102; LEFT: 9px; POSITION: absolute; TOP: 71px" runat="server" Width="189px" Height="25px" TextMode="MultiLine"></asp:textbox>
                            <asp:button id="SearchButton" style="Z-INDEX: 103; LEFT: 11px; POSITION: absolute; TOP: 108px" runat="server" Width="75px" Height="20px" Text="Search" CssClass="sortbtn"></asp:button>
                            <input type="image" src="go.gif" onclick="return checkingpeop();" width="19" height="14">
                            <asp:label Height="21px" id="Label2" runat="server" Width="129px" style="Z-INDEX: 105; LEFT: 11px; POSITION: absolute; TOP: 170px" class="FontStyle">
           Documents found:</asp:label>
                            <asp:label id="FileCount" style="Z-INDEX: 104; LEFT: 148px; POSITION: absolute; TOP: 170px" runat="server" Font-Bold="True" Width="97px" Height="20px"></asp:label>
                            <asp:datagrid id="SearchResultsGrid" style="Z-INDEX: 107; LEFT: 12px; POSITION: absolute; TOP: 200px" runat="server" Width="449px" Height="473px" AllowPaging="True" BackColor="#B7D0E4" CssClass="FontStyle">
                                  <AlternatingItemStyle BorderStyle="Solid" CssClass="fontstyle" BackColor="Transparent"></AlternatingItemStyle>
                                  <HeaderStyle Font-Bold="True" ForeColor="Black" CssClass="fontstyle" BackColor="PeachPuff"></HeaderStyle>
                                  <PagerStyle Font-Bold="True" HorizontalAlign="Left" Mode="NumericPages"></PagerStyle>
                <ITEMSTYLE BackColor="AntiqueWhite"></ITEMSTYLE>
                <HEADERSTYLE Font-Bold="True" BorderWidth="2px" BorderColor="#0000C0"></HEADERSTYLE></FORM>
    So when we try to click on the Go button the error "System.Web.HttpException: The viewstate is invalid for this page and might be corrupted." occurs

    This is the code for the parent form which calls all the  three frames:
    <%@ Page %>
                <title>Welcome to T.S Search</title>
          <frameset name="mainFrame" frameborder="0" framespacing="0" border="0" cols="*" rows="68,*,20">
                <frame name="banner" marginwidth="0" marginheight="0" target="main" src="maintoptssearch.aspx" name="heading" noresize scrolling="no">
                <frameset name="sideFrame" frameborder="0" framespacing="0" border="0" cols="200,12,*" rows="*">
                      <frameset name="innerFrame" frameborder="0" framespacing="0" border="0" cols="*" rows="1000,0,*">
                            <frame marginwidth="8" marginheight="0" name="contents" target="main" src="tsdocumentsearch.aspx?Type=People" name="code" noresize scrolling="auto" frameborder="0">
                      <frame marginwidth="50" marginheight="50" src="toggle.html" name="toggle" noresize scrolling="auto">
                      <frameset name="innerFrameout" frameborder="0" framespacing="0" border="0" cols="*" rows="1000,*">
                            <frame marginwidth="5" marginheight="5" name="main" id="main" src="maintssearch.aspx" noresize scrolling="auto">
                <p>The <code>NOFRAMES</code> element is to be used to give useful content to people
                      with browsers that cannot display frames. One example is Lynx, a text-based

    pleased to give you any more clarifications
    LVL 35

    Expert Comment

    in the @Page directive set EnableViewStateMAC to false
    LVL 35

    Accepted Solution

    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="Tsdocumentsearch.aspx.vb" EnableViewStateMAC="false" Inherits="IRDtsearchDevelopmentnew.Tsdocumentsearch"%>
    LVL 1

    Author Comment


    Thanks Yzalt

    I was using this EnableviewstateMAc = "False" in the page initialize event that was the reason it didn't work
    Any way thanks now it works fine..!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now