How to make Base64 string url safe

G

Guest

In a asp.net site i need to make a url link like this:
http://server.com/test.aspx?base64=...Dn8WTw5zigKErw6QFxaF+wrvDksOkwqjDq1fCrsOewrc=

I've used the Convert.ToBase64String() to make the querystring parameter

But as you can see the second char is a "+". When receiving the parameter in
the test.aspx page this + gets replaced with an empty space " ".
On test.aspx i receive the parameter like this:

string test = Request.QueryString["base64"];


I've read there two articeles without finding a super nice way of making a
base64 string url safe

http://www.codeproject.com/aspnet/ScrambleQueryStrings.asp
http://www.codeproject.com/aspnet/EncodedUrlBuilder.asp
 
G

Guest

Yes, with no luck.

/Rasmus




Karl Seguin said:
Have you tried simply calling URLEncode on the value?

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Rasmus said:
In a asp.net site i need to make a url link like this:
http://server.com/test.aspx?base64=...Dn8WTw5zigKErw6QFxaF+wrvDksOkwqjDq1fCrsOewrc=

I've used the Convert.ToBase64String() to make the querystring parameter

But as you can see the second char is a "+". When receiving the parameter
in
the test.aspx page this + gets replaced with an empty space " ".
On test.aspx i receive the parameter like this:

string test = Request.QueryString["base64"];


I've read there two articeles without finding a super nice way of making a
base64 string url safe

http://www.codeproject.com/aspnet/ScrambleQueryStrings.asp
http://www.codeproject.com/aspnet/EncodedUrlBuilder.asp
 
K

Karl Seguin [MVP]

I did some quick tests and it seems to work.

<a id="x" runat="server">test</a>

x.HRef = string.Format("tmp2.aspx?x={0}",
HttpUtility.UrlEncode("c+KAnMOfxZLDqhd2w4DCtMOmwr8hawkCdsK9YH7igqwITuKAmcOhXAcDxbjFoR3Cum/DqwFJRU7DpzbigJlYZD1cJcKBwqgaBsObw6VxMMW9wrTDpD7CpSTDkeKAuuKAlFfDt8W+Jz3CvhM7w5HCjeKAneKAuT3Dn8WTw5zigKErw6QFxaF+wrvDksOkwqjDq1fCrsOewrc="));


and then I echo out the querystring and all's good..

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/


Rasmus said:
Yes, with no luck.

/Rasmus




Karl Seguin said:
Have you tried simply calling URLEncode on the value?

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Rasmus said:
In a asp.net site i need to make a url link like this:
http://server.com/test.aspx?base64=...Dn8WTw5zigKErw6QFxaF+wrvDksOkwqjDq1fCrsOewrc=

I've used the Convert.ToBase64String() to make the querystring
parameter

But as you can see the second char is a "+". When receiving the
parameter
in
the test.aspx page this + gets replaced with an empty space " ".
On test.aspx i receive the parameter like this:

string test = Request.QueryString["base64"];


I've read there two articeles without finding a super nice way of
making a
base64 string url safe

http://www.codeproject.com/aspnet/ScrambleQueryStrings.asp
http://www.codeproject.com/aspnet/EncodedUrlBuilder.asp
 
G

Guest

ok, but what happens when you after the sumbit do:

string test = Request.QueryString["x"];

/rasmus

Karl Seguin said:
I did some quick tests and it seems to work.

<a id="x" runat="server">test</a>

x.HRef = string.Format("tmp2.aspx?x={0}",
HttpUtility.UrlEncode("c+KAnMOfxZLDqhd2w4DCtMOmwr8hawkCdsK9YH7igqwITuKAmcOhXAcDxbjFoR3Cum/DqwFJRU7DpzbigJlYZD1cJcKBwqgaBsObw6VxMMW9wrTDpD7CpSTDkeKAuuKAlFfDt8W+Jz3CvhM7w5HCjeKAneKAuT3Dn8WTw5zigKErw6QFxaF+wrvDksOkwqjDq1fCrsOewrc="));


and then I echo out the querystring and all's good..

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/


Rasmus said:
Yes, with no luck.

/Rasmus




Karl Seguin said:
Have you tried simply calling URLEncode on the value?

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


In a asp.net site i need to make a url link like this:
http://server.com/test.aspx?base64=...Dn8WTw5zigKErw6QFxaF+wrvDksOkwqjDq1fCrsOewrc=

I've used the Convert.ToBase64String() to make the querystring
parameter

But as you can see the second char is a "+". When receiving the
parameter
in
the test.aspx page this + gets replaced with an empty space " ".
On test.aspx i receive the parameter like this:

string test = Request.QueryString["base64"];


I've read there two articeles without finding a super nice way of
making a
base64 string url safe

http://www.codeproject.com/aspnet/ScrambleQueryStrings.asp
http://www.codeproject.com/aspnet/EncodedUrlBuilder.asp
 
K

Karl Seguin [MVP]

it worked for me...

karl

Rasmus said:
ok, but what happens when you after the sumbit do:

string test = Request.QueryString["x"];

/rasmus

Karl Seguin said:
I did some quick tests and it seems to work.

<a id="x" runat="server">test</a>

x.HRef = string.Format("tmp2.aspx?x={0}",
HttpUtility.UrlEncode("c+KAnMOfxZLDqhd2w4DCtMOmwr8hawkCdsK9YH7igqwITuKAmcOhXAcDxbjFoR3Cum/DqwFJRU7DpzbigJlYZD1cJcKBwqgaBsObw6VxMMW9wrTDpD7CpSTDkeKAuuKAlFfDt8W+Jz3CvhM7w5HCjeKAneKAuT3Dn8WTw5zigKErw6QFxaF+wrvDksOkwqjDq1fCrsOewrc="));


and then I echo out the querystring and all's good..

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/


Rasmus said:
Yes, with no luck.

/Rasmus




:

Have you tried simply calling URLEncode on the value?

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


In a asp.net site i need to make a url link like this:
http://server.com/test.aspx?base64=...Dn8WTw5zigKErw6QFxaF+wrvDksOkwqjDq1fCrsOewrc=

I've used the Convert.ToBase64String() to make the querystring
parameter

But as you can see the second char is a "+". When receiving the
parameter
in
the test.aspx page this + gets replaced with an empty space " ".
On test.aspx i receive the parameter like this:

string test = Request.QueryString["base64"];


I've read there two articeles without finding a super nice way of
making a
base64 string url safe

http://www.codeproject.com/aspnet/ScrambleQueryStrings.asp
http://www.codeproject.com/aspnet/EncodedUrlBuilder.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top