ASP + Ajax + __VIEWSTATE = BAD ?

G

GTi

I have a ASP 2.0 page where I use some Ajax code. The Ajax code
(JavaScript) is inserted from CodeBehind.
In my page I have a submit button and some links for Ajax functions.
When I load the page and use the submit button it give me some results
that is fine.
Then I press the links that activate the Ajax Code the results is
displayed fine on my page.
- BUT -
If I then press the submit button again I get this error:
"The state information is invalid for this page and might be corrupted"
That happens only if I activate the Ajax Code. If I don't I can press
the submit button without any problems.

I think the whole problem is the hidden __VIEWSTATE.
I don't think I use it at all - Is it possible to remove it and still
have sessions variables?

Screen output:
-----------------------------------------------------------------------------------------
Source Error:
[No relevant source lines]

Source File: d:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary
ASP.NET Files\mes\80fad5dd\dd8b6fcb\App_Web_aehuzojs.4.cs Line: 0

Stack Trace:
[FormatException: Invalid character in a Base-64 string.]
System.Convert.FromBase64String(String s) +0
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
+72

System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String
serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter,
String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +140

[ViewStateException: Invalid viewstate.
Client IP: 127.0.0.1
Port: 4406
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1
ViewState:
/wEPDwUKMTc5OTcyNjkwMg9kFgICAw9kFgICAQ8WAh4JaW5uZXJodG1sBeUsCgo8IS0tIEFVVE8gQ09OVEVOVCAtLT48aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJBQkJNRVNET0NXSVRIIiBpZD0iQUJCTUVTRE9DV0lUSCIgdmFsdWU9IjAiIC8+PGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQUJCTUVTRE9DSElHSFQiIGlkPSJBQkJNRVNET0NISUdIVCIgdmFsdWU9IjAiIC8+PCEtLSBFTkQgT0YgQVVUTyBDT05URU5UIC0tPgo8IS0tIEJFR0lOTklORyBPRiBDT05URU5UIFNFQ1RJT04gLS0+PGRpdiBzdHlsZT0iaGVpZ2h0OjEwcHgiPjwvZGl2Pgo8ZmllbGRzZXQgY2xhc3M9RmllbGRzZXRDbGFzcz48dGFibGUgY2xhc3M9VGV4dEZpZWxkIGJvcmRlcj0iMCI+PHRyPjx0ZD5TZWxlY3QgUmVwb3J0IHR5cGU6PGJyLz48c2VsZWN0IGNsYXNzPUVkaXRGaWVsZCBzaXplPSIxIiBuYW1lPSJSZXBvcnRUeXBlIiB0aXRsZT0iU2VsZWN0IFJlcG9ydCB0eXBlIiBvbmNoYW5nZT0idGhpcy5mb3JtLnN1Ym1pdCgpOyIgPjxvcHRpb24gdmFsdWU9IjAiID5TZWxlY3QgUmVwb3J0IHR5cGU8L29wdGlvbj48b3B0aW9uIHZhbHVlPSIxIiA+U2VhcmNoIGJ5IERhdGU8L29wdGlvbj48b3B0aW9uIHZhbHVlPSIyIiBzZWxlY3RlZCA+U2VhcmNoIEVuZCBQcm...]

[HttpException (0x80004005): The state information is invalid for this
page and might be corrupted.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String
persistedState, String errorPageMessage, Boolean macValidationError)
+116
System.Web.UI.HiddenFieldPageStatePersister.Load() +240
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +83
System.Web.UI.Page.LoadAllState() +35
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+6953
System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+154
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
+18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.pluginpage_aspx.ProcessRequest(HttpContext context) in
d:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\mes\80fad5dd\dd8b6fcb\App_Web_aehuzojs.4.cs:0

System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+154
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +64
 
S

Sonu Kapoor

To disable the ViewState use the EnableViewState property and set it to false. Although I believe that you should check why you are getting this error. If you are using a third party ajax library, then you might want to ask the author about that as well.

Sonu Kapoor [MVP]
 
G

GTi

My bad !!!
My Ajax code was returning a complete html page including a new
__VIEWSTATE field.
After a Page.Response.Clear() in the Ajax result code it works just
fine !!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top