not valid Base64 character when doing redirect with query string

I was having a problem in my checkout page, the problem that i had was i’ve got this memberID from the checkout page and it’s being passed to another page via query string. This problem doesn’t happen everytime and it happens rarely, this is what i hate the most!!. After spending a couple of hours, i found the problem is in the query string it self.

when you pass something like this in query string


and it will be automatically converted becoming

“c ckDQiiilyW4r7moRA8oQ==”

and when you try to decrypt it, it will throw the exception of “not valid Base64 character”

“+” when you pass it to url it will be automatically converted to ” “(blank space)

The work around of this problem is

on the target page, you can do some string replace of ” “(blank space) with “+” , and voila it works!!!!

Dim strQuery As String = Request.QueryString("OrderID")
strQuery = strQuery.Replace(" ", "+")

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s