Errors: Failed to load viewstate. & Validation of viewstate MAC failed.

Discussion in 'ASP .Net' started by sck10, Aug 31, 2006.

  1. sck10

    sck10 Guest

    Hello,

    I have applications that produce the following error when they have been
    open to long without activity. Is there any way to force a re-load of the
    page or go to another page if the page has expired instead of getting the
    error?

    Thanks,


    Failed to load viewstate. The control tree into which viewstate is being
    loaded must match the control tree that was used to save viewstate during
    the previous request. For example, when adding controls dynamically, the
    controls added during a post-back must match the type and position of the
    controls added during the initial request.


    Server Error in '/' Application.
    Validation of viewstate MAC failed. If this application is hosted by a Web
    Farm or cluster, ensure that <machineKey> configuration specifies the same
    validationKey and validation algorithm. AutoGenerate cannot be used in a
    cluster.
    sck10, Aug 31, 2006
    #1
    1. Advertising

  2. sck10

    KJ Guest

    A few preliminary questions: are you hosted on a web farm; if so, do
    you have enableViewStateMac set to false in your Web.Config, for
    example:

    <pages enableViewStateMac="false"/>

    sck10 wrote:
    > Hello,
    >
    > I have applications that produce the following error when they have been
    > open to long without activity. Is there any way to force a re-load of the
    > page or go to another page if the page has expired instead of getting the
    > error?
    >
    > Thanks,
    >
    >
    > Failed to load viewstate. The control tree into which viewstate is being
    > loaded must match the control tree that was used to save viewstate during
    > the previous request. For example, when adding controls dynamically, the
    > controls added during a post-back must match the type and position of the
    > controls added during the initial request.
    >
    >
    > Server Error in '/' Application.
    > Validation of viewstate MAC failed. If this application is hosted by a Web
    > Farm or cluster, ensure that <machineKey> configuration specifies the same
    > validationKey and validation algorithm. AutoGenerate cannot be used in a
    > cluster.
    KJ, Aug 31, 2006
    #2
    1. Advertising

  3. sck10

    sck10 Guest

    Hi KJ,

    No, I am not on a web farm...

    Thanks, sck10


    "KJ" <> wrote in message
    news:...
    >A few preliminary questions: are you hosted on a web farm; if so, do
    > you have enableViewStateMac set to false in your Web.Config, for
    > example:
    >
    > <pages enableViewStateMac="false"/>
    >
    > sck10 wrote:
    >> Hello,
    >>
    >> I have applications that produce the following error when they have been
    >> open to long without activity. Is there any way to force a re-load of
    >> the
    >> page or go to another page if the page has expired instead of getting the
    >> error?
    >>
    >> Thanks,
    >>
    >>
    >> Failed to load viewstate. The control tree into which viewstate is being
    >> loaded must match the control tree that was used to save viewstate during
    >> the previous request. For example, when adding controls dynamically, the
    >> controls added during a post-back must match the type and position of the
    >> controls added during the initial request.
    >>
    >>
    >> Server Error in '/' Application.
    >> Validation of viewstate MAC failed. If this application is hosted by a
    >> Web
    >> Farm or cluster, ensure that <machineKey> configuration specifies the
    >> same
    >> validationKey and validation algorithm. AutoGenerate cannot be used in a
    >> cluster.

    >
    sck10, Aug 31, 2006
    #3
  4. sck10

    KJ Guest

    In this case, I don't have a correct answer for you. You could try the
    following links:

    http://www.andreas-kraus.net/blog/validation-of-viewstate-mac-failed/
    http://dotnetjunkies.com/WebLog/thomasswilliams/archive/2006/06/06/139890.aspx

    sck10 wrote:
    > Hi KJ,
    >
    > No, I am not on a web farm...
    >
    > Thanks, sck10
    >
    >
    > "KJ" <> wrote in message
    > news:...
    > >A few preliminary questions: are you hosted on a web farm; if so, do
    > > you have enableViewStateMac set to false in your Web.Config, for
    > > example:
    > >
    > > <pages enableViewStateMac="false"/>
    > >
    > > sck10 wrote:
    > >> Hello,
    > >>
    > >> I have applications that produce the following error when they have been
    > >> open to long without activity. Is there any way to force a re-load of
    > >> the
    > >> page or go to another page if the page has expired instead of getting the
    > >> error?
    > >>
    > >> Thanks,
    > >>
    > >>
    > >> Failed to load viewstate. The control tree into which viewstate is being
    > >> loaded must match the control tree that was used to save viewstate during
    > >> the previous request. For example, when adding controls dynamically, the
    > >> controls added during a post-back must match the type and position of the
    > >> controls added during the initial request.
    > >>
    > >>
    > >> Server Error in '/' Application.
    > >> Validation of viewstate MAC failed. If this application is hosted by a
    > >> Web
    > >> Farm or cluster, ensure that <machineKey> configuration specifies the
    > >> same
    > >> validationKey and validation algorithm. AutoGenerate cannot be used in a
    > >> cluster.

    > >
    KJ, Aug 31, 2006
    #4
  5. Hello Steve,

    From your description, the problem occurs when the page has been idle for
    long time. Does it occur when the page is display in short time and be
    fresh? For long time idle page, I think the exception is likely due to the
    viewstate MAC has been expired and the server runtime can not validate it.
    ASP.NET will perform a simple digest on the viewstate and check it later
    when page postback, however, this digest is not valid forever, after long
    period, it could refresh it. I've also seen some one encountering such
    problem when using page cached in google page cache.

    For your another question:
    ================
    Is there any way to force a re-load of the
    page or go to another page if the page has expired instead of getting the
    error?
    ================

    Do you think use client-side script to set a timer and postback/reload the
    page after a certain periold workable for you? e.g.

    #the following page use script to reload the page after 20 secs
    ==================
    ....................
    <script type="text/javascript">
    function client_onload()
    {
    window.setTimeout("refresh_page()", 20000);
    }

    function refresh_page()
    {
    window.location.href = window.location.href;
    }
    </script>
    </head>
    <body onload="client_onload();">
    <form id="form1" runat="server" >
    <div>
    ..............
    ===============

    Hope this helps.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Sep 1, 2006
    #5
  6. sck10

    sck10 Guest

    Thanks KJ, I'll check out the site...


    "KJ" <> wrote in message
    news:...
    > In this case, I don't have a correct answer for you. You could try the
    > following links:
    >
    > http://www.andreas-kraus.net/blog/validation-of-viewstate-mac-failed/
    > http://dotnetjunkies.com/WebLog/thomasswilliams/archive/2006/06/06/139890.aspx
    >
    > sck10 wrote:
    >> Hi KJ,
    >>
    >> No, I am not on a web farm...
    >>
    >> Thanks, sck10
    >>
    >>
    >> "KJ" <> wrote in message
    >> news:...
    >> >A few preliminary questions: are you hosted on a web farm; if so, do
    >> > you have enableViewStateMac set to false in your Web.Config, for
    >> > example:
    >> >
    >> > <pages enableViewStateMac="false"/>
    >> >
    >> > sck10 wrote:
    >> >> Hello,
    >> >>
    >> >> I have applications that produce the following error when they have
    >> >> been
    >> >> open to long without activity. Is there any way to force a re-load of
    >> >> the
    >> >> page or go to another page if the page has expired instead of getting
    >> >> the
    >> >> error?
    >> >>
    >> >> Thanks,
    >> >>
    >> >>
    >> >> Failed to load viewstate. The control tree into which viewstate is
    >> >> being
    >> >> loaded must match the control tree that was used to save viewstate
    >> >> during
    >> >> the previous request. For example, when adding controls dynamically,
    >> >> the
    >> >> controls added during a post-back must match the type and position of
    >> >> the
    >> >> controls added during the initial request.
    >> >>
    >> >>
    >> >> Server Error in '/' Application.
    >> >> Validation of viewstate MAC failed. If this application is hosted by a
    >> >> Web
    >> >> Farm or cluster, ensure that <machineKey> configuration specifies the
    >> >> same
    >> >> validationKey and validation algorithm. AutoGenerate cannot be used in
    >> >> a
    >> >> cluster.
    >> >

    >
    sck10, Sep 1, 2006
    #6
  7. sck10

    sck10 Guest

    Steven,

    Thanks for the timer script. That may be the solution I need...



    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hello Steve,
    >
    > From your description, the problem occurs when the page has been idle for
    > long time. Does it occur when the page is display in short time and be
    > fresh? For long time idle page, I think the exception is likely due to the
    > viewstate MAC has been expired and the server runtime can not validate it.
    > ASP.NET will perform a simple digest on the viewstate and check it later
    > when page postback, however, this digest is not valid forever, after long
    > period, it could refresh it. I've also seen some one encountering such
    > problem when using page cached in google page cache.
    >
    > For your another question:
    > ================
    > Is there any way to force a re-load of the
    > page or go to another page if the page has expired instead of getting the
    > error?
    > ================
    >
    > Do you think use client-side script to set a timer and postback/reload the
    > page after a certain periold workable for you? e.g.
    >
    > #the following page use script to reload the page after 20 secs
    > ==================
    > ...................
    > <script type="text/javascript">
    > function client_onload()
    > {
    > window.setTimeout("refresh_page()", 20000);
    > }
    >
    > function refresh_page()
    > {
    > window.location.href = window.location.href;
    > }
    > </script>
    > </head>
    > <body onload="client_onload();">
    > <form id="form1" runat="server" >
    > <div>
    > .............
    > ===============
    >
    > Hope this helps.
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    >
    > ==================================================
    >
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    >
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    >
    > ==================================================
    >
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    >
    sck10, Sep 1, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ray Stevens

    Validation of viewstate MAC failed

    Ray Stevens, Aug 4, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    804
    Brock Allen
    Aug 9, 2005
  2. Not Me

    Validation of viewstate MAC failed

    Not Me, Dec 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    470
    Not Me
    Dec 8, 2005
  3. Sergej Grickov

    Error: Validation of viewstate MAC failed

    Sergej Grickov, Jan 27, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    11,656
    Teemu Keiski
    Feb 4, 2006
  4. aaaaaa
    Replies:
    1
    Views:
    424
    Alvin Bruney - ASP.NET MVP
    Mar 23, 2006
  5. Dhruba Bandopadhyay
    Replies:
    1
    Views:
    21,630
    Alvin Bruney
    May 25, 2006
Loading...

Share This Page