ASP.NET Erreur:L'état de l'information n'est pas valide pour cette page et peut être endommagé.

Je n'ai pas de JQuery ou javascript en changeant les valeurs ou html-structure. Et je n'ai pas de contrôles qui est ajouté dynamiquement.

Encore, je reçois l'erreur: Les informations d'état n'est pas valide pour cette page et peut être endommagé

L'erreur se produit un peu aléatoire. Voici comment je peux reproduire le problème, aspx fichier:

<%@ Page ViewStateEncryptionMode ="Never" MaxPageStateFieldLength="40" ValidateRequest="false" Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeFile="tbTest.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>tbTest </title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Button id="Submit1" type="submit"  
        runat="server" onClick="btnclick_Click" Text="Submit" /><br />
    <asp:TextBox ID="tbStatus" enableViewState="true" runat="server" TextMode="MultiLine" 
        Width="617px" Height="67px" ReadOnly="True" Font-Size="Smaller"></asp:TextBox>
    <br />
   </form>
</body>
</html>

.cs-fichier:

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Init(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DateTime timestamp = DateTime.Now;
            try
            {
                tbStatus.Text = timestamp.ToString() + ". Page Loaded. ";
            }catch (Exception ex) {
            }
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            try
            {
                Response.Cache.SetNoStore();
            } catch (Exception ex){
            } 
        }    
    }

    protected void btnclick_Click(object sender, EventArgs e)
    {
        DateTime timestamp = DateTime.Now;
        try
        {
            tbStatus.Text += Environment.NewLine + timestamp.ToString() + ". TextBox updated. ";

        } catch (Exception ex) {
            tbStatus.Text += Environment.NewLine + timestamp.ToString() + ". Error. " + ex.Message.ToString();
        }
    }
}

Cela me donne vraiment la tête de l'ache. Après 3-4 soumet l'erreur est là. J'ai testé la modification des valeurs pour ViewStateEncryptionMode, MaxPageStateFieldLength, ValidateRequest, AutoEventWireup et EnableEventValidation sans succès.

Ce qui peut être mauvais?

OriginalL'auteur Plarsen | 2014-01-17