Should I ignore the occasional Invalid viewstate error?

后端 未结 10 589
小鲜肉
小鲜肉 2020-12-07 08:42

Every now and then (once every day or so) we\'re seeing the following types of errors in our logs for an ASP.NET 3.5 application

  • Invalid viewstate
  • Inv
10条回答
  •  囚心锁ツ
    2020-12-07 09:27

    invalid view state don't have any value for your logger or for users or for your website,End users never sees those errors. to avoid this error try to add the following In Global.ascx:

    void Application_Error(object sender, EventArgs e)
        {          
                    if (ex is HttpException && ex.InnerException is ViewStateException)
                    {
                        Response.Redirect(Request.Url.AbsoluteUri);
                        return;
                    }
        }
    

    for more info check the following link:

    https://www.karpach.com/viewstateexception-invalid-viewstate.htm

提交回复
热议问题