1

Good Morning. I inherited a program when I took an IT position, and I am not very SQL/VB savvy.

Also, I have researched this error online, but in trying their solution, I still get the error.

This is the error I receive:

Message: Invalid length for a Base-64 char array or string. Source: mscorlib Method: FromBase64_Decode Line: 0 Column: 0 Case:
Case ID: 0 Active Tab: 0 Last Active Tab: 0 Current List ID: 0

Stack Trace: at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength) at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength) at System.Convert.FromBase64String(String s)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) at System.Web.UI.HiddenFieldPageStatePersister.Load()

I believe it comes from the UrlDecode of this sample code in VB Studio 2012:

Case "CaseSetup"
hlCaseSetupLink.Text = getShortFileNameFromPath(sPath)
hlCaseSetupLink.NavigateUrl = "File:///" & sPath
hlCaseSetupLink.NavigateUrl = HttpUtility.UrlDecode(hlCaseSetupLink.NavigateUrl)
updateCaseSetup()

Just before the last line updateCaseSetup(), I inserted the following code to compensate for any spaces the UrlDecode created with a plus sign to maintain the Base-64 compatibility:

hlCaseSetupLink.NavigateUrl = Replace(hlCaseSetupLink.NavigateUrl, " ", "+")

Also, to put this in reference, this code is for the 8 tabs created in the custom program I use and is repeated 8 times but with different tab names in the code.

Does this make sense to anyone?

Thank you all for your time. It is greatly appreciated.

RBarryYoung
  • 55,398
  • 14
  • 96
  • 137
IT guy
  • 11
  • 1
  • 5
  • Umm, what you are showing us does not look like SQL code at all, nor is that error from SQL Server, AFAIK. PLease show us more of the code and especially, more context as to what you are doing and how this is being executed. – RBarryYoung Sep 10 '15 at 14:32
  • Apologies for the confusion, @RBarryYoung, it is Visual Basic code utilizing information from SQL Server 2008. The context is a Menu with 8 tabs. Once a customer is selected, you have 8 tabs to choose from relating to specifics with the customer. This code is from a subroutine and repeated 7 other times with slight differences. As far as additional code, I am not sure what else you need. – IT guy Sep 10 '15 at 14:50
  • Is the error new since the aforementioned change? Or did you make the change after the error started occurring? – RBarryYoung Sep 10 '15 at 16:18
  • Can you show us what is in NavigateUrl when the error occurs? – RBarryYoung Sep 10 '15 at 16:25
  • @RBarryYoung I made the change after the error occurred. I am not able to show the NavigateURL information because I cannot recreate the error in Debug mode ( and I have tried many times). I only get the error notifications. – IT guy Sep 10 '15 at 16:59
  • Have whatever is creating your error notifications include the NavigateUrl text. – RBarryYoung Sep 10 '15 at 17:02
  • The error message comes from deserializing an object, the `UrlDecode` method doesn't do any deserializing. A more likely candidate would be something like a corrupted viewstate string. – Guffa Sep 10 '15 at 17:34
  • 1
    @RBarryYoung I am still trying to find whatever is creating my error notifications, but as soon as I do, I'll include that value – IT guy Sep 11 '15 at 14:52
  • @Guffa I appreciate the input but I have no idea what a viewstate string is or where to look for it. – IT guy Sep 11 '15 at 14:53
  • You probably have a LoggingProvider that is being called from an error handler. – RBarryYoung Sep 11 '15 at 15:04
  • @ITguy: The viewstate string is placed in a hidden field in the page, and is used to preserve state for server controls. Data from server controls are serialised into the string, and then deserialised at postback. I'm not sure that it's the viewstate string, but it's clear from the call stack that it's data from a hidden field that is deserialised. – Guffa Sep 11 '15 at 16:13
  • Thank you all for your time in helping me out with this issue. I realize that my limited knowledge with asp.net and inability to find viewstate strings or where my error handler is kept has forced me to hire someone from the outside to handle this issue. Before I do I am trying one more method that pads the string with equal signs before decryption to see if that resolves the issue. – IT guy Sep 22 '15 at 13:51

1 Answers1

0

Have a look at: What causing this "Invalid length for a Base-64 char array"

After urlDecode processes the text, it replaces all '+' chars with ' '. To make it base 64 compatible again, replace ' ' with '+' as in above solution.

Community
  • 1
  • 1
radkan
  • 599
  • 4
  • 9