开发者

Invalid viewstate information may be corrupted

I keep getting the following error message when I run my vb.net web app:

The state information is invalid for this page and might be corrupted.

View full message here.

After a good search, I came across this Microsoft page, which describes the problem exactly. The likely cause seems to be "scenario 2":

Scenario 2: You modify your pag开发者_运维技巧es, which causes the shadow, copied files in the Temporary ASP.NET files folder to be regenerated. A user has a copy of the page that was requested before this change, and the user posts the page after the files in that folder were regenerated.

But strangely- despite saying there is a hotfix, does not actually give the link to it.

Can anyone suggest a fix?

UPDATED: I appear to have prevented this error from happening by using EnableEventValidation="False" in the Page node of the markup as recommended here. More of a work-around than a fix.


It is not recommended to disable EnableEventValidation as explained in Page.EnableEventValidation Property.

I got this issue before and came over it by deleting all files within ASP.NET Temporary Folder.

Folder Path:

.NET 2 : C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
.NET 4: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files


IN one of my project, I was getting this error in Mozilla Firefox only that whenever i clicked a button or link.

It is because of the fact that firefox caches the form fields. Two ways to encounter this problem.

  1. Write following snipet in your cs file

    protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); if (Request.Browser.MSDomVersion.Major == 0) // If it is Non IE Browser { Response.Cache.SetNoStore(); } }

  2. In page load, write following statemet

    Response.Cache.SetNoStore();

Now error has been removed and you can sleep with satisfaction.

http://yourtahir.wordpress.com/2008/06/26/the-state-information-is-invalid-for-this-page-and-might-be-corrupted/


Might be overdate, but this cured my viewstate problems with ajax calls to page control. Custom CompressedViewState : add this code :

private ObjectStateFormatter _formatter = new ObjectStateFormatter();
protected override void
           SavePageStateToPersistenceMedium(object viewState)
    {
        MemoryStream ms = new MemoryStream();
        _formatter.Serialize(ms, viewState);
        byte[] viewStateArray = ms.ToArray();
        ClientScript.RegisterHiddenField("__COMPRESSEDVIEWSTATE",
            Convert.ToBase64String(
            CompressViewState.Compress(viewStateArray)));
    }
    protected override object LoadPageStateFromPersistenceMedium()
    {
        string vsString = Request.Form["__COMPRESSEDVIEWSTATE"];
        byte[] bytes = Convert.FromBase64String(vsString);
        bytes = CompressViewState.Decompress(bytes);
        return _formatter.Deserialize(
            Convert.ToBase64String(bytes));
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜