开发者

Invalid view state exception in asp.net. do you know any solution?

this problem make me crazy! i have asp.net website it raise periodically this error (in IE8):

    System.Web.HttpException: Invalid viewstate.
       at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType)
       at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler
.ProcessRequest(HttpContext context)
    ,...

or (in IE6)

System.FormatException: Invalid length for a开发者_开发问答 Base-64 char array.
   at System.Convert.FromBase64String(String s)
   at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)

or (in IE7)

System.FormatException: Invalid character in a Base-64 string.
   at System.Convert.FromBase64String(String s)
   at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)

i set enableViewStateMac in web.config to false and defined machinekey in my web.config and defined UTF-8 encoding for every page but i received this errors.


do you have any solution?

best regards


Are you performing databinding on the page more than once when a page loads? This error will occur if you do that.


If you are binding during your Page_Load event use the IsPostBack flag of the your Page object so binding only occurs once during load.

e.g.

if (!Page.IsPostBack)
{
    //Perform Binding Here
}

But if you are dynamically adding ascx controls programmatically you will need to bind these on every subsequent post back.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜