2013-05-06 12 views
5

Il mio sito web sta lanciando le seguenti eccezioni ogni giorno e non sono riuscito a trovare la soluzione. ho fatto poche ricerche nel web e questo è quello che faccio finora. l'aggiunta dell'opzione sottostante ad aspx non risolverà il problema.System.Web.UI.ViewStateException, viewstate non valido

ValidateRequest = "false" EnableEventValidation = "false" ViewStateEncryptionMode = "Mai" EnableViewStateMac = "false"

Inoltre, il mio Referral URL è l'URL corretto e non ho idea di come riorientare con due (uguali) parametri. non esiste questo link nella mia pagina di riferimento. Per favore aiuto.

LOG ERRORI

URL : http://www.abcd.com/company-details.aspx?com=asia-pacific-pte-ltd&com=asia-pacific-pte-ltd 

referral URL : http://www.abcd.com/companies/asia-pacific-pte-ltd/ 

Inner Exception Type: System.Web.UI.ViewStateException 

Inner Exception: Invalid viewstate. Client IP: 192.162.19.193 Port: 1966 User-Agent: Opera/9.80 (Windows NT 6.1; WOW64; MRA 6.0 (build 6001)) Presto/2.12.388 Version/12.11 ViewState: /wEPDwULLTEyMTAyMTY3NDAPZBYCAgMPZBYOZg8QDxYGHg1EYXRhVGV4dEZpZWxkBQdDb3VudHJ5Hg5EYXRhVmFsdWVGaWVsZAUNQ2xlYW5fQ291bnRyeR4LXyFEYXRhQm91bmRnZBAVCgNBbGwFQ2hpbmEJSG9uZyBLb25nBUluZGlhCUluZG9uZXNpYQhNYWxheXNpYQtQaGlsaXBwaW5lcwlTaW5nYXBvcmUIVGhhaWxhbmQHVmlldG5hbRUKA0FsbAVjaGluYQlob25nLWtvbmcFaW5kaWEJaW5kb25lc2lhCG1hbGF5c2lhC3BoaWxpcHBpbmVzCXNpbmdhcG9yZQh0aGFpbGFuZAd2aWV0bmFtFCsDCmdnZ2dnZ2dnZ2dkZAIBDxAPFgYfAAUISW5kdXN0cnkfAQUOQ2xlYW5fSW5kdXN0cnkfAmdkEBXFAgNBbGwSQWR2YW5jZWQgTWF0ZXJpYWxzC0FkdmVydGlzaW5nCkFlc3RoZXRpY3MLQWdyaWN1bHR1cmUkQWdyaWN1bHR1cmUgLSBBZ3JpY3VsdHVyYWwgTWFjaGluZXJ5G0FncmljdWx0dXJlICYgRm9vZCBQcm9kdWN0cxBBaXItY29uZGl0aW9uaW5nHUFpci1maWx0cmF0aW9uICYgUHVyaWZpY2F0aW9uB0FpcnBvcnQJQWx1bWluaXVtFEFuYWx5dGljYWwgRXF1aXBtZW50GkFuYWx5dGljYWwgSW5zdHJ1bWVudGF0aW9uFUFuYWx5dGljYWwgVGVjaG5vbG9neRZBbmQgSW50ZXJpb3IgRGVzaWduZXJzEUFuaW1hbCBQcm9kdWN0aW9uCEFudGlib2R5KUFwc... 

Inner Source: 

Exception Type: System.Web.HttpException 

Exception: The state information is invalid for this page and might be corrupted. 

Stack Trace: at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) at System.Web.UI.HiddenFieldPageStatePersister.Load() at System.Web.UI.Page.LoadPageStateFromPersistenceMedium() at System.Web.UI.Page.LoadAllState() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.exhibition_details_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\0f461847\442b0502\App_Web_bfjqxdef.20.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

UPDATE ho fissato l'errore comprimendo il ViewState da sotto il collegamento http://www.codeproject.com/Articles/14733/ViewState-Compression

e fissata la lunghezza non valida per un errore di allineamento Base-64 char sostituendo il metodo originale con questo.

protected override object LoadPageStateFromPersistenceMedium() 
    { 
     string viewState = Request.Form["__VSTATE"]; 
     viewState = viewState.Replace(" ", "+"); 

     int mod4 = viewState.Length % 4; 
     if (mod4 > 0) 
     { 
      viewState += new string('=', 4 - mod4); 
     } 
     byte[] bytes = Convert.FromBase64String(viewState); 
     bytes = Compressor.Decompress(bytes); 
     LosFormatter formatter = new LosFormatter(); 
     return formatter.Deserialize(Convert.ToBase64String(bytes)); 
    } 

Grazie a tutti per l'aiuto :)

risposta

3

Mi dispiace che dicono che ma il vostro sito non ha avuto nulla, ed è necessario riattivare l'EventValidations il più presto possibile.

Quello che vedi è an attempt to hack your site inviando molti test numbers with your ViewState trying to find your hash key.

IP you give have a big list of activity the last few days.

Ora, l'alternativa che potrebbe causare questo errore è l'interruzione di ViewState. Puoi compress it and split it se hai ViewState troppo grande. Puoi anche disable all the controls that not needed. Inoltre è possibile aggiungere un log to see from inside what's is going on right on a base page.

+1

Ho rimosso questi EnableEventValidation = "false" ViewStateEncryptionMode = "Never" EnableViewStateMac = "false" e lo ha compresso dal collegamento che mi hai fornito e ha risolto il problema. grazie mille :) – bluebird

+0

sto ricevendo questi errori ora, però, lunghezza non valida per un array di char Base-64. help – bluebird

+0

@ user597729 Se lo vedi solo nel log, controlla l'IP, come ti dico che è probabilmente un tentativo di hacking e non devi preoccuparti. Se lo vedi come utente ... allora forse è un problema. – Aristos

0

sì che funziona anche per me

qui a vbnet

Compressor.vb

Imports System.IO 
Imports System.IO.Compression 
Public Class Compressor 

Public Shared Function Compress(ByVal data() As Byte) As Byte() 
    Dim output As MemoryStream = New MemoryStream 
    Dim gzip As GZipStream = New GZipStream(output, CompressionMode.Compress, True) 
    gzip.Write(data, 0, data.Length) 
    gzip.Close() 
    Return output.ToArray 
End Function 

Public Shared Function Decompress(ByVal data() As Byte) As Byte() 
    Dim input As MemoryStream = New MemoryStream 
    input.Write(data, 0, data.Length) 
    input.Position = 0 
    Dim gzip As GZipStream = New GZipStream(input, CompressionMode.Decompress, True) 
    Dim output As MemoryStream = New MemoryStream 
    Dim buff() As Byte = New Byte((64) - 1) {} 
    Dim read As Integer = -1 
    read = gzip.Read(buff, 0, buff.Length) 

    While (read > 0) 
     output.Write(buff, 0, read) 
     read = gzip.Read(buff, 0, buff.Length) 

    End While 

    gzip.Close() 
    Return output.ToArray 
End Function 
End Class 

e questo si incolla all'interno default.aspx ha bisogno

Imports System.IO

Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object 
    Dim viewState As String = Request.Form("__VSTATE") 
    Dim bytes() As Byte = Convert.FromBase64String(viewState) 
    bytes = Compressor.Decompress(bytes) 
    Dim formatter As LosFormatter = New LosFormatter 
    Return formatter.Deserialize(Convert.ToBase64String(bytes)) 
End Function 

Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object) 
    Dim formatter As LosFormatter = New LosFormatter 
    Dim writer As StringWriter = New StringWriter 
    formatter.Serialize(writer, viewState) 
    Dim viewStateString As String = writer.ToString 
    Dim bytes() As Byte = Convert.FromBase64String(viewStateString) 
    bytes = Compressor.Compress(bytes) 
    ClientScript.RegisterHiddenField("__VSTATE", Convert.ToBase64String(bytes)) 
End Sub