Invalid viewstate (System.String DecryptStringWithIV

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JamTech
    New Member
    • Jan 2009
    • 3

    Invalid viewstate (System.String DecryptStringWithIV

    The Script Resource and the Web Resource files are generating intermittent errors in my application. I have been trying to chase the cause of the problem but to no avail. I notice that the “d” parameter that is passed is some how corrupted and I can’t for the life of me figure out what’s causing this parameter to be corrupted. I noticed that JavaScript code that in my application is some how getting intertwined with the hash code that’s generated for the “d” parameter. I have below the entire stack trace:

    Exception genereated on Monday, January 26, 2009, at 2:20 AM
    Page location: /ScriptResource. axd?d=y9_dUwBeG qLlRpT5Dml1zhoQ vfa7NKdj69EYuV7 71kzSsa5KOOXBfJ Zjk%20%20%20%20 %20%20%20%20%20 %20%20%20if%20( cat_gallery%20! =
    Requested Url : Buy Garmin GPS Nuvi 350, Nuvi 660, C330 and more at Garmin Factory Outlet Store if (cat_gallery !=
    Message: Exception has been thrown by the target of an invocation.
    Source: mscorlib
    Method: System.Object _InvokeMethodFa st(System.Objec t, System.Object[], System.Signatur eStruct ByRef, System.Reflecti on.MethodAttrib utes, System.RuntimeT ypeHandle)
    Stack Trace: at System.RuntimeM ethodHandle._In vokeMethodFast( Object target, Object[] arguments, SignatureStruct & sig, MethodAttribute s methodAttribute s, RuntimeTypeHand le typeOwner) at System.RuntimeM ethodHandle.Inv okeMethodFast(O bject target, Object[] arguments, Signature sig, MethodAttribute s methodAttribute s, RuntimeTypeHand le typeOwner) at System.Reflecti on.RuntimeMetho dInfo.Invoke(Ob ject obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityC hecks) at System.Reflecti on.RuntimeMetho dInfo.Invoke(Ob ject obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflecti on.MethodBase.I nvoke(Object obj, Object[] parameters) at System.Web.Hand lers.ScriptReso urceHandler.Dec ryptString(Stri ng s) at System.Web.Hand lers.ScriptReso urceHandler.Dec ryptParameter(N ameValueCollect ion queryString) at System.Web.Hand lers.ScriptReso urceHandler.Pro cessRequest(Htt pContext context) at System.Web.Hand lers.ScriptReso urceHandler.Sys tem.Web.IHttpHa ndler.ProcessRe quest(HttpConte xt context) at System.Web.Http Application.Cal lHandlerExecuti onStep.System.W eb.HttpApplicat ion.IExecutionS tep.Execute() at System.Web.Http Application.Exe cuteStep(IExecu tionStep step, Boolean& completedSynchr onously)
    Inner Exception: System.Web.Http Exception: Invalid viewstate. at System.Web.UI.P age.DecryptStri ngWithIV(String s, IVType ivType) at System.Web.UI.P age.DecryptStri ng(String s)
    User IP: 74.34.62.187

    BaseMessage : Exception genereated on Monday, January 26, 2009, at 2:20 AM
    Page location: /ScriptResource. axd?d=y9_dUwBeG qLlRpT5Dml1zhoQ vfa7NKdj69EYuV7 71kzSsa5KOOXBfJ Zjk%20%20%20%20 %20%20%20%20%20 %20%20%20if%20( cat_gallery%20! =
    Requested Url : Buy Garmin GPS Nuvi 350, Nuvi 660, C330 and more at Garmin Factory Outlet Store if (cat_gallery !=
    Message: Invalid viewstate.
    Source: System.Web
    Method: System.String DecryptStringWi thIV(System.Str ing, System.Web.Conf iguration.IVTyp e)
    Stack Trace: at System.Web.UI.P age.DecryptStri ngWithIV(String s, IVType ivType) at System.Web.UI.P age.DecryptStri ng(String s)
    User IP: 74.34.62.187
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 1.1.4322; Zune 3.0)
  • JamTech
    New Member
    • Jan 2009
    • 3

    #2
    Issue with ScriptResource and WebResource

    I have been analyzing the data that I have been collecting and I have drawn a few conclusions. I noticed that a large majority of the errors that I have been getting are coming from windows Vista computers running IE 8 or Firefox 3. There where also a few cases where it was Vista and IE 7. This could explain why the errors are now just becoming an issue as more and more people are using the new operating system.



    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; FunWebProducts; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GoogleT5; MSN Optimized;CA; MSN Optimized;CA)
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; GTB5; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0)





    But anyways the conclusion that I want to get at is that based on this information I started looking into how the browsers process java scripts and if there was anything new that could be causing this issue, that’s when something interesting pop out at me, I found on the w3School website an article about the difference in html vs. xhtml.



    Differences between HTML and XHTML
    HTML 4 and XHTML deal different with the content inside scripts:

    In HTML 4, the content type is declared as CDATA, which means that entities will not be parsed.
    In XHTML, the content type is declared as (#PCDATA), which means that entities will be parsed.
    This means that in XHTML, all special characters should be encoded or all content should be wrapped inside a CDATA section.

    To ensure that a script parses correctly in an XHTML document, use the following syntax:

    So I immediately took a look into my code and I saw that the DOCTYPE directive was missing on some of my pages the sameones that are causing the Issue. I also noticed that where I was outputting JavaScript using the .NET Register Client Script routine it would wrap the inner content of the script tags with the CDATA attribute, while where there was the regular JavaScript written on the page there was no CDATA used. For example



    <script language=”javas cript”>

    Function RunMe() {

    }

    </script>



    I am no expert on how browser’s renders or parse the html return, but I strongly believe it has some thing to do with the situation above because the Url parameter in the Script Resource request whenever it crashes always contains code in between script tags that's below it. Some times there is even html style sheet code that can be found there as well. For example



    http://braun.factoryoutletstore.com/...sY8V_8function runSearchForFie ld(eventObj, id){ if ((eventObj.whic h == 13) || (eventObj.keyCo de == 13)) { var cat_gallery = getParam('galle ry'); var cat = getParam('cat') var searchTerm = escape(document .getElementById (id).value); // must use escape() function to urlencode search term to avoid issues with '&' and '=' symbols var url; if (cat_







    http://braun.factoryoutletstore.com/...5j_0hD8to_aPDj <tr> <td class=





    Now what am thinking is that some how because am not specifying any DOCTYPE in the page the browser might be trying to infer based on the data its receiving then it ends up messing up because sometimes there is CDATA and there are times when there is no CDATA present in the page. I don’t know really if this is a solid assumption cause as they say assumptions as dangerous. If anyone can shade some light on my theory and let me know if the browsers are parsing the xhtml differently that older version or even if they had any similar situations.

    Comment

    • JamTech
      New Member
      • Jan 2009
      • 3

      #3
      This has solved my issue

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        All new web pages are required to use a doctype to conform with current HTML. IE8 will be about 10 years behind in DOM support compared to FF3 and every other browser. I didn't go through everything you posted but that's the jist of things.

        Comment

        • cedLeb
          New Member
          • Apr 2009
          • 1

          #5
          I"m having the same problem. I verified my pages the doctype is present. So if anyone have an idea on how to resolve this i ll be grateful.

          Comment

          Working...