Showing posts with label viewstate. Show all posts
Showing posts with label viewstate. Show all posts

Monday, March 26, 2012

Periodically ViewState verification fail

Hi I hope you can help me with this problem:

Checking the event viewer of a Web Application I have noticed that periodically happens a ViewState Verification fail. It happens several times by day on a diferent .aspx pages. Sometimes it causes an error and the user loses his data, but other times apparently user can continue using the application.

This is the event registered ( I have changed the computer name and the path data, but it's not importante for the question)

COMPUTER_NAMEEvent code: 4009
Event message: Viewstate verification failed.Reason: The viewstate supplied failed integrity check.Event time: 10/8/2006 6:54:00 PM
Event time (UTC): 10/8/2006 4:54:00 PM
Event ID: 78a9d00b907b4edab1ac37665fa3175c Event sequence: 447 Event occurrence: 2 Event detail code: 50203
Application information:
Application domain: /LM/W3SVC/250184202/Root/ApplicationPath-1-128047877472787699
Trust level: Full
Application Virtual Path: /ApplicationName Application Path: D:\Directory\www\ ApplicationName \ Machine name: COMPUTER_NAME
Process information: Process ID: 2916
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Request information:
Request URL: http://ApplicationName /ApplicationForm.aspx
Request path: ApplicationName /ApplicationForm.aspx
User host address: 80.66.205.47User: USER@dotnet.itags.org.application.com
Is authenticated: True
Authentication Type: Custom
Thread account name: NT AUTHORITY\NETWORK SERVICE
ViewStateException information: Exception message: Invalid viewstate. Client IP: 80.98.185.47
Port: 16528 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7 PersistedState: ML0cSytZ3NNxTv6HMBICK (… Here appears lines and lines of the viewstate dumped) … LecAy+p3fFVSdi7LZEE= Referer: http://ApplicationName /ApplicationForm.aspx
Path: ApplicationName/ApplicationForm.aspx aspx
Custom event details:10/8/20066:01:15 PMASP.NET 2.0.50727.0InformationWeb Event 1316N/A

Any help would be appreciated

Thanks

There are a lot of possible causes for this issue. You can take a look this KB:

Troubleshooting the "View State is invalid" error with ASP.NET


Hi expert, I am also having this type of error. The first error from different user is this one:

Event code: 4009

Event message: Viewstate verification failed. Reason: The viewstate supplied failed integrity check.

Then another error, from different user is this:

Event code: 4005

Event message: Forms authentication failed for the request. Reason: The ticket supplied was invalid.

Please advise. Thanks.

Friday, March 16, 2012

Persistent ViewState

Hello everybody!
Imagine a form with several TextBox WebControls and two buttons "New" which
should clear the form and "Save". On reloading or leaving the page which
holds the form the TextBoxes should be cleared so I've disabled the
ViewStates of these TextBoxes by setting the EnableViewState property to
false.
The method which is bound to the OnClick event of the "New" button is
empty. When clicked a PostBack occurs which, theoretically, should be
sufficient to clear the TextBoxes because their state shouldn't be saved.
Unfortunately after the PostBack the data is still there! I've had a look
into the HTML source and found out that the value property of the TextBoxes
is set, so there's still a ViewState?! Even a ViewState.Clear() and/or
ClearChildViewState() within OnClick() doesn't work!
Disabling the ViewState for the whole page is no solution because the page
also contains a DataGrid and other controls which depend on the ViewState.
Please help!
Sincerely
Sven JacobsViewState is a different state persistance mechanism than the normal <form>
post data. ViewState is for data that is not part of the normal POST. The
text in a Label is saved in ViewState because a <span> doesn't post when
the form is submitted. The text in a TExtBox will be submitted, and thus
disabling viewstate has no effect on that.
-Brock
DevelopMentor
http://staff.develop.com/ballen

> Hello everybody!
> Imagine a form with several TextBox WebControls and two buttons "New"
> which should clear the form and "Save". On reloading or leaving the
> page which holds the form the TextBoxes should be cleared so I've
> disabled the ViewStates of these TextBoxes by setting the
> EnableViewState property to false.
> The method which is bound to the OnClick event of the "New" button is
> empty. When clicked a PostBack occurs which, theoretically, should be
> sufficient to clear the TextBoxes because their state shouldn't be
> saved. Unfortunately after the PostBack the data is still there! I've
> had a look into the HTML source and found out that the value property
> of the TextBoxes is set, so there's still a ViewState?! Even a
> ViewState.Clear() and/or ClearChildViewState() within OnClick()
> doesn't work!
> Disabling the ViewState for the whole page is no solution because the
> page also contains a DataGrid and other controls which depend on the
> ViewState.
> Please help!
>
> ViewState is a different state persistance mechanism than the normal <form>
> post data. ViewState is for data that is not part of the normal POST. The
> text in a Label is saved in ViewState because a <span> doesn't post when
> the form is submitted. The text in a TExtBox will be submitted, and thus
> disabling viewstate has no effect on that.
So what you saying is that the state persistance of a form is a feature of
HTTP / the browser? How to clear the form then, via JavaScript?
Thanks!
Sincerely
Sven Jacobs
> So what you saying is that the state persistance of a form is a feature of
> HTTP / the browser? How to clear the form then, via JavaScript?
Forget that! After reading this article
http://aspalliance.com/articleViewer.aspx?aId=135 I think I now what the
difference between ViewState and PostBack data is.
So what I have to do is not to import the PostBack data on a special
condition (=New button clicked).
Sincerely
Sven Jacobs
No, the form persistance is a feature of the ASP.NET runtime, in that it
matches the control id in the POST data and fills the associated value from
that. See
http://msdn.microsoft.com/library/d...br />
tate.asp
To clear the form, loop through the controls on the form, and check if the
control is a textbox, or certain type of control, then set the value to an
empty string, or index to -1 if a droplist etc. It really depends on what
type of control you are working with as there is no generic way of clearing
a form (AFAIK).
- Paul Glavich
ASP.NET MVP
ASPInsider (www.aspinsiders.com)
"Sven Jacobs" <sven.jacobs@.web.de> wrote in message
news:178f7ojd7o9bi.719p7zwjzasv$.dlg@.40tude.net...
<form>
The
> So what you saying is that the state persistance of a form is a feature of
> HTTP / the browser? How to clear the form then, via JavaScript?
> Thanks!
> --
> Sincerely
> Sven Jacobs

Persistent ViewState

Hello everybody!

Imagine a form with several TextBox WebControls and two buttons "New" which
should clear the form and "Save". On reloading or leaving the page which
holds the form the TextBoxes should be cleared so I've disabled the
ViewStates of these TextBoxes by setting the EnableViewState property to
false.

The method which is bound to the OnClick event of the "New" button is
empty. When clicked a PostBack occurs which, theoretically, should be
sufficient to clear the TextBoxes because their state shouldn't be saved.
Unfortunately after the PostBack the data is still there! I've had a look
into the HTML source and found out that the value property of the TextBoxes
is set, so there's still a ViewState?! Even a ViewState.Clear() and/or
ClearChildViewState() within OnClick() doesn't work!

Disabling the ViewState for the whole page is no solution because the page
also contains a DataGrid and other controls which depend on the ViewState.

Please help!

--
Sincerely
Sven JacobsViewState is a different state persistance mechanism than the normal <form>
post data. ViewState is for data that is not part of the normal POST. The
text in a Label is saved in ViewState because a <span> doesn't post when
the form is submitted. The text in a TExtBox will be submitted, and thus
disabling viewstate has no effect on that.

-Brock
DevelopMentor
http://staff.develop.com/ballen

> Hello everybody!
> Imagine a form with several TextBox WebControls and two buttons "New"
> which should clear the form and "Save". On reloading or leaving the
> page which holds the form the TextBoxes should be cleared so I've
> disabled the ViewStates of these TextBoxes by setting the
> EnableViewState property to false.
> The method which is bound to the OnClick event of the "New" button is
> empty. When clicked a PostBack occurs which, theoretically, should be
> sufficient to clear the TextBoxes because their state shouldn't be
> saved. Unfortunately after the PostBack the data is still there! I've
> had a look into the HTML source and found out that the value property
> of the TextBoxes is set, so there's still a ViewState?! Even a
> ViewState.Clear() and/or ClearChildViewState() within OnClick()
> doesn't work!
> Disabling the ViewState for the whole page is no solution because the
> page also contains a DataGrid and other controls which depend on the
> ViewState.
> Please help!
> ViewState is a different state persistance mechanism than the normal <form>
> post data. ViewState is for data that is not part of the normal POST. The
> text in a Label is saved in ViewState because a <span> doesn't post when
> the form is submitted. The text in a TExtBox will be submitted, and thus
> disabling viewstate has no effect on that.

So what you saying is that the state persistance of a form is a feature of
HTTP / the browser? How to clear the form then, via JavaScript?

Thanks!

--
Sincerely
Sven Jacobs
> So what you saying is that the state persistance of a form is a feature of
> HTTP / the browser? How to clear the form then, via JavaScript?

Forget that! After reading this article
http://aspalliance.com/articleViewer.aspx?aId=135 I think I now what the
difference between ViewState and PostBack data is.

So what I have to do is not to import the PostBack data on a special
condition (=New button clicked).

--
Sincerely
Sven Jacobs
No, the form persistance is a feature of the ASP.NET runtime, in that it
matches the control id in the POST data and fills the associated value from
that. See
http://msdn.microsoft.com/library/d...l/viewstate.asp

To clear the form, loop through the controls on the form, and check if the
control is a textbox, or certain type of control, then set the value to an
empty string, or index to -1 if a droplist etc. It really depends on what
type of control you are working with as there is no generic way of clearing
a form (AFAIK).

--

- Paul Glavich
ASP.NET MVP
ASPInsider (www.aspinsiders.com)

"Sven Jacobs" <sven.jacobs@.web.de> wrote in message
news:178f7ojd7o9bi.719p7zwjzasv$.dlg@.40tude.net...
> > ViewState is a different state persistance mechanism than the normal
<form>
> > post data. ViewState is for data that is not part of the normal POST.
The
> > text in a Label is saved in ViewState because a <span> doesn't post when
> > the form is submitted. The text in a TExtBox will be submitted, and thus
> > disabling viewstate has no effect on that.
> So what you saying is that the state persistance of a form is a feature of
> HTTP / the browser? How to clear the form then, via JavaScript?
> Thanks!
> --
> Sincerely
> Sven Jacobs