2012-01-20 13 views
7

¿Alguien me puede ayudar con esta excepción? He intentado algunas correcciones, pero nada funcionó. Recibo esta excepción solo en IE (7, 8 y 9).La información de estado no es válida para esta página y podría estar dañada. (Solo en IE)

Cuando cargo la página por primera vez, aparece un menú desplegable. donde selecciono un proveedor específico y devuelve una publicación de página y devuelve la información requerida. Si cambio el proveedor, aún cargará la información. Cuando cargo un control en la página utilizando dinámicamente la solicitud $ .ajax y luego retrocedo y cambio la selección desplegable (seleccione un proveedor diferente), se produce un error y me da la siguiente excepción. Nuevamente solo sucede en el IE.

The state information is invalid for this page and might be corrupted. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: The state information is invalid for this page and might be corrupted. 

Source Error: 


[No relevant source lines] 


Source File: c:\Users\tmalik\AppData\Local\Temp\Temporary ASP.NET Files\root\6691c708\751e6443\App_Web_a3kdfsht.2.cs Line: 0 

Stack Trace: 


[FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters. ] 
    System.Convert.FromBase64String(String s) +0 
    System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +77 
    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() +147 

[ViewStateException: Invalid viewstate. 
    Client IP: 127.0.0.1 
    Port: 
    Referer: http://localhost:57289/vendor.aspx 
    Path: /vendor.aspx 
    User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; MDDR) 
    ViewState: 2D1IMRanPXfVARbRp1ooiwD71WHybNzxSNLbbA0G3MxKeo7m52dHWLBPGdnMH5JthTnPVt7UES/PVx39dfZYHbr0/DL7J58mvA2I4wRUSdDShVxvZqC7ZPZWcatowpZ7VYaD9PFKW7OkgppCwmePFuYnpU8kWDT5TvSLqN50Flrqpv0zCM9YoCKemfesa68rqBkkSTijcxnxdDCgvzSl72giI4ZhwK92wD22Ma6scW4PFjRZeTsKoowJq+JqJGuBMEepwKguFUy4dX86UIULnJ7NQsgZW1aQvpZdnfSRCSYrWhFWPhKTPsS622eaQYShsxddPs/mfEB26f54WS+iBYuk3mWm8jr6sWvsOIRtwH8b3E/5UujbgAxTNVg8BhzpSFvmE4KwGKo0tKuuqOFtP0pjpaAI7fV3EQ1M7BVQSAVrtBevRFJ0PlCPrU2aQms2LVeE5POqTJGtY+74xWkdCtLzT04Ug4R+SMBRElQBqX/5A54OHj2ghYjJ/3tgg4ToGUX2xrQ/c70lrphP+kabGVM2Op4DFjZAaOZj/CDVUurH2BYXKuJdUvzbf2zHngoOnqZGqrw3n6V6HGcnHNKxfuGQ20MPdxJYCbYHGiRqixzV1NxJoHFHbYCVx3IlrqF0W44AFKm2gzzk3V8zu9lUjyFNvUNBMjNaZeekLtcWpszhKrm8WhVnWQAk1CXxKJqyK0RC3...] 

[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) +235 
    System.Web.UI.ViewStateException.ThrowViewStateError(Exception inner, String persistedState) +14 
    System.Web.UI.HiddenFieldPageStatePersister.Load() +251 
    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +106 
    System.Web.UI.Page.LoadAllState() +43 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431 
    System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253 
    System.Web.UI.Page.ProcessRequest() +78 
    System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21 
    System.Web.UI.Page.ProcessRequest(HttpContext context) +49 
    ASP.vendor_aspx.ProcessRequest(HttpContext context) in c:\Users\tmalik\AppData\Local\Temp\Temporary ASP.NET Files\root\6691c708\751e6443\App_Web_a3kdfsht.2.cs:0 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 
+1

Perseguiría esto: "La entrada no es una cadena válida Base-64 ya que contiene un carácter no base de 64 caracteres, más de dos caracteres de relleno, o un carácter de espacio no blanco entre los caracteres de relleno". – DOK

+1

Creo que sé mi problema. Agregar controles dinámicos (ajaxly) a la página cambia el estado de visualización y cuando publicamos la página devuelve una excepción ya que viewstate ha cambiado. He utilizado un truco para eliminar todos los placefoldes (es decir, Div) utilizando jquery en el backpage de página. Lo que significa eliminar todo el estado de visualización agregado. aquí es mi solución $ ("# VendorListDropDownSearchable") cambio (function() { $ ("# UserControl1DIV") remove();. $ ("# UserControl2DIV") remove();. }.); – Tauseef

+1

¡Genial! Si confirma que esto resuelve su problema, vuelva aquí y cree una respuesta. Eso realmente ayudará a otras personas que seguramente encontrarán su camino hasta aquí. He tenido exactamente este mismo mensaje de error, simplemente no podía recordar. Está perfectamente bien para responder a sus propias preguntas (lo dice en las preguntas frecuentes). – DOK

Respuesta

11

Bien, entonces aquí está la solución/hack que se me ocurrió. Mi problema era que agregar un control de usuario dinámicamente (a través de una solicitud ajax) en la página cambiaba el estado de la vista de la página y lanzaba una excepción. Tras la investigación, descubrí que viewstate almacena el estado de una página (propiedades y configuraciones). Una vez que devuelva los controles html desde un servicio web, habrá algún tipo de viewstate almacenado en la página. Y cuando publique nuevamente en el servidor, arrojará una excepción cuando descifre el viewstae para reconstruir la página. Simplemente eliminé esos controles (que se agregaron dinámicamente) en la publicación de la página usando jquery y se resolvió el problema.

//In my case "VendorListDropDownSearchable", causes the page post back. 
    $("#VendorListDropDownSearchable").change(function() { 
     $("#UserControl1DIV").remove(); //removing the place holder holding control1 
     $("#UserControl2DIV").remove(); //same as above 
    }); 
+0

Tauseef @Tauseef hola tiene el mismo problema. solo en ie. – Mohammadreza

+0

Totalmente tenía el mismo problema. ¡Gracias por publicar una respuesta! –

+0

Tuve el mismo problema solo en IE9 (la página funcionó bien en IE10). Tuve que agregar un OnClientClick a mi botón ASP.Net, para llamar a una función de Javascript como la suya, antes de intentar ejecutar algún código C#, para redirigir a una página ASP.Net diferente. –

4

Sé que esto ha sido contestada, pero aquí hay un par de otras opciones:

1). Si estás haciendo una llamada de servicio web a través de .load jQuery() sólo se puede quitar el estado de vista a su regreso utilizando cargas parámetro de devolución de llamada

$('#myDiv').load('/MyPage.aspx', null, function(){ 
    $('.aspNetHidden', this).remove(); // removes viewstate from returned aspx html 
}); 

2). Uso de Html Agility Pack Puede hacer lo mismo en un servicio web antes de mostrar el control devuelto. Supongamos que está llamando a un servicio web que carga un UserControl.ascx en el servicio y luego procesa su html antes de regresar.

[WebMethod(EnableSession = true)] 
[System.Web.Script.Services.ScriptMethod] 
public string GetControlHtml() 
{ 

// do stuff to get the control you want 

.... 

Page page = new Page(); 
HtmlForm form = new HtmlForm(); 
var ctl = (MyControlsNameSpace.Controls.MyControl)page.LoadControl("Controls\\MyControl.ascx"); 

page.Controls.Add(form); 
form.Controls.Add(ctl); 
StringWriter result = new StringWriter(); 
HttpContext.Current.Server.Execute(page, result, false); 

// Extension Method RemoveViewStateFromControl 
var MyControlsHTML = result.RemoveViewStateFromControl(); 
return MyControlsHTML; 

} 

..... 

// In an extensions class.... 
public static string RemoveViewStateFromExecuteControl(this StringWriter writer) 
    { 
     HtmlAgilityPack.HtmlDocument Doc = new HtmlDocument(); 
     Doc.LoadHtml(writer.ToString()); 
     var Divs = Doc.DocumentNode.SelectNodes("//div"); 
     if (Divs != null) 
     { 
      foreach (var Tag in Divs) 
      { 
       if (Tag.Attributes["class"] != null) 
       { 
        if (string.Compare(Tag.Attributes["class"].Value, "aspNetHidden", StringComparison.InvariantCultureIgnoreCase) == 0) 
        { 
         Tag.Remove(); 
        } 
       } 
      } 
     } 

     return Doc.DocumentNode.OuterHtml; 
    } 
+1

+1 para su respuesta # 1: $ ('. AspNetHidden', this) .remove(); Intenté EnableViewState = "false", EnableViewStateMac = "false", ViewStateMode = "Disabled" en mi página interna (jquery cargada), ninguno de ellos impidió que aparecieran los divs aspNetHidden, lo que arruinó el viewstate de la página padre. (Error aplicado a todos los navegadores para mí.) –

+0

este fue el problema real. ¡Gracias! – CodeIt

1

En mi caso, el problema fue tener dos <form></form> etiquetas.

Tengo un TextBox en mi página principal. Si el usuario ingresa un valor en este TextBox, un Script va a otra página y busca ese valor mientras el usuario continúa escribiéndolo. Normalmente creé esta página "otra" haciendo clic en Website, Add New Item. Así que Visual Studio creó una nueva página para mí. Como de costumbre, también había <form></form> en esta nueva página. Así que borré estas etiquetas y el problema fue resuelto.

continuación son mis códigos:

(PS:. Yo uso MasterPage Pero el código de abajo sólo es necesario en mi página principal)

Dim scriptText As String 
    scriptText = "" 
    scriptText += "function serinogoster(str) {" + Chr(10) 
    scriptText += "var xhttp;" + Chr(10) 
    scriptText += "if (str == '') {" + Chr(10) 
    scriptText += "document.getElementById('ctl00_ContentPlaceHolder1_Label19').innerHTML = '';" + Chr(10) 
    scriptText += "return;" + Chr(10) 
    scriptText += "}" + Chr(10) 
    scriptText += "xhttp = new XMLHttpRequest();" + Chr(10) 
    scriptText += "xhttp.onreadystatechange = function() {" + Chr(10) 
    scriptText += "if (this.readyState == 4 && this.status == 200) {" + Chr(10) 
    scriptText += "document.getElementById('ctl00_ContentPlaceHolder1_Label19').innerHTML = this.responseText;" + Chr(10) 
    scriptText += "}" + Chr(10) 
    scriptText += "};" + Chr(10) 
    scriptText += "xhttp.open('GET', 'serinover.aspx?serino='+str, true);" + Chr(10) 
    scriptText += "xhttp.send();" + Chr(10) 
    scriptText += "}" + Chr(10) 
    Me.ClientScript.RegisterClientScriptBlock(Me.GetType(), "OnKeyUpScript", scriptText, True) 
    TextBox6.Attributes.Add("onkeyup", "serinogoster(this.value);") 

En el código serinover.aspx arriba es la segunda página que debería no tiene la etiqueta <form></form>.

Cuestiones relacionadas