ASP.NET错误:状态信息是这个页面无效,可能已损坏 [英] ASP.NET Error:The state information is invalid for this page and might be corrupted

查看:209
本文介绍了ASP.NET错误:状态信息是这个页面无效,可能已损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有JQuery的或其他JavaScript改变数值或html结构。我没有动态添加控件。

I have no JQuery or other javascript changing values or html-structure. And I have no controls that is added dynamically.

不过我得到的错误:的状态信息是这个页面无效,可能已损坏

错误发生,有些随机。这里是我可以复制的问题,ASPX文件:

The error occurs somewhat random. Here is how I can replicate the issue, aspx-file:

<%@ 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文件:

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();
        }
    }
}

这真的让我头疼。 3-4后提交的错误是存在的。我已经测试了 ViewStateEncryptionMode,MaxPageStateFieldLength,ValidateRequest,AutoEventWireup EnableEventValidation 没有成功改变的值。

This really gives me head-ache. After 3-4 submits the error is there. I have tested changing values for ViewStateEncryptionMode, MaxPageStateFieldLength, ValidateRequest, AutoEventWireup and EnableEventValidation without success.

什么可能是错的?

推荐答案

只需设置enableEventValidation属性中的asp.net应用程序,以虚假的web.config文件。

Just set the enableEventValidation attribute in the web.config file for the asp.net application to false.

可能还需要检查
<一href=\"http://blog.syedgakbar.com/2007/11/one-possible-reason-for-the-state-information-is-invalid-for-this-page-exception/\" rel=\"nofollow\">http://blog.syedgakbar.com/2007/11/one-possible-reason-for-the-state-information-is-invalid-for-this-page-exception/

http://support.microsoft.com/default。 ?ASPX SCID = KB; EN-US; 829743

IIS COM pression也可能导致此。验证这是关闭的。

IIS compression enabled on IIS6 can also cause this. Verify this is turned off.

这篇关于ASP.NET错误:状态信息是这个页面无效,可能已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆