"Invalid character in Base-64 string" using ASP.NET and C #

I had a problem publishing the page. There is jquery ajax load on the page, called when replacing the dropdown list, if I disable onchange, the message works.

"Status information is invalid for this page and may be corrupted."

[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() +113 [ViewStateException: invalid Viewstate. Client IP: 127.0.0.1 Port: User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) ViewState: /+UiQgMjUwLjAwMCwwMDwvc3Ryb25nPmQCCQ8WAh8ABRUxNTYwLjQ0IG08c3VwPjI8L3N1cD5kAgsPFgIfAAUJMyBlIDQgIEQuZAINDw8WBh8ABRBFeGNsdWlyIGRhIGxpc3RhHgdUb29sVGlwBRBFeGNsdWlyIGRhIGxpc3RhHgtOYXZpZ2F0ZVVybAUUI3JlbW92ZUxpbmsgMjEwMDM3NzlkZAIPDw8WBh8DBUB+L3ZlbmRhL2xhbmNhbWVudG...] [HttpException (0x80004005): As informações sobre estado são inválidas para esta página e podem estar corrompidas.] System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +106 System.Web.UI.ViewStateException.ThrowViewStateError(Exception inner, String persistedState) +14 System.Web.UI.HiddenFieldPageStatePersister.Load() +217 System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +105 System.Web.UI.Page.LoadAllState() +43 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242 System.Web.UI.Page.ProcessRequest() +80 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21 System.Web.UI.Page.ProcessRequest(HttpContext context) +49 ASP.content_search_default_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\web-site-2009\e4bfc9d6\d5d6c855\App_Web_zcb1qfmu.0.cs:0 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 

what could be the reason for this? Has anyone seen this before?

thanks

EDIT:

So, I found out why this is happening. At the end of Page_Load, I write a javascript line that calls the jquery function, which loads the new fields into the div. So, as I see it, this creates an inconsistency in the view. Disabling ViewState is not an option for this case. It works on FF and this causes errors in IE. Is anyone

thanks

+3
source share
3 answers

Just stumbled upon this. Remove the form tag from the page you are loading via jquery.

+5
source

For the same problem, the reason I got the error was that I submitted the full form as a string to the javascript method, and then placed the form.

It was a bit heavy, and my fix was to send only the form data as serialized json, and then create and publish the form via javascript, as in this post.

http://weblogs.asp.net/hajan/archive/2011/03/16/posting-from-asp-net-webforms-page-to-another-url.aspx

0
source

An invalid view state does not matter for your registrar or for users or your site, to avoid this error, try adding the following to 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 information check the following link:

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

0
source

Source: https://habr.com/ru/post/1337217/


All Articles