473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

URLEncode/Decode

Nic
Hello all,

I ran into a problem encoding/decoding special characters in URLs.
by using Server.UrlEncode and Server.UrlDecode.
Basically, encoding x+y results in x%2by, however decoding
x%2by results in x y (missing the +).

Anyway to solve this?

Thanks,

Nic
Nov 18 '05 #1
2 5659
Nic wrote:
Hello all,

I ran into a problem encoding/decoding special characters in URLs.
by using Server.UrlEncode and Server.UrlDecode.
Basically, encoding x+y results in x%2by, however decoding
x%2by results in x y (missing the +).


This does not happen to me:

Console.WriteLine( HttpUtility.UrlDecode( "x%2by"));
I'm guessing that what's happening is that you're passing in to
UrlDecode a string that you've gotten from Request.QueryString[] (or
something similar).

The strings in the QueryString collection have already been decoded, so
you would be in effect decoding the string twice which would result in
the behavior you're seeing ('+' gets decoded into a space).

--
mikeb
Nov 18 '05 #2
Nic
Mike, thanks for your reply. You're right, the string I am passing is
already decoded by
Request.QueryString

Nic
"mikeb" <ma************@nospam.mailnull.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Nic wrote:
Hello all,

I ran into a problem encoding/decoding special characters in URLs.
by using Server.UrlEncode and Server.UrlDecode.
Basically, encoding x+y results in x%2by, however decoding
x%2by results in x y (missing the +).


This does not happen to me:

Console.WriteLine( HttpUtility.UrlDecode( "x%2by"));
I'm guessing that what's happening is that you're passing in to
UrlDecode a string that you've gotten from Request.QueryString[] (or
something similar).

The strings in the QueryString collection have already been decoded, so
you would be in effect decoding the string twice which would result in
the behavior you're seeing ('+' gets decoded into a space).

--
mikeb

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: C | last post by:
Hi, If I redirect a user to a page and encode the url, do I need to decode it on the page they are redirected to. For Eample.. Response.Redirect...
3
by: Doug Johnston | last post by:
Hi, I am having problems with running urlencode(select * from myfile where field like '%0002%'), in particular the like section, what I get is... like+%27%250002%25%27 ....which is fine, but...
5
by: elyob | last post by:
Quite a lot of my data has apostrophes in. I'm passing the data using $_POST and urlencode. So, for example, Joe's becomes Joe%27s. On the next page, I urldecode and display the name in the META...
2
by: Grey | last post by:
How can I use the URLEncode in ASP.NET?? If i used URLEncode to encode the URL, how can I decode the URL with proper parameter values in ASP.NET?? I can encode the URL, but i cannot decode it...
2
by: Marc Cardinal | last post by:
I have a need to encode and decode url content. I'm currently using the UrlDecode and UrlEncode methods from the HttpUtility class. However the code must be able to run under the .Net Internet...
0
by: darrel | last post by:
I'm trying to pass a text string via a querystring. I'm using URLEncode to pass it and URLDecode to grab it. This works, unless the string has an apostrphy in it. Is there a reason that...
1
by: lookaround | last post by:
Hi, I have a problem with UrlEncoding/UrlDecoding. I have two chars (東京); the HTTPUtility.UrlEncode writes in the html the text: %e6%9d%b1%e4%ba%ac The Request.Querystring.ToString() of...
2
by: gouqizi.lvcha | last post by:
For ASP.Net 2.0, if using HttpUtilities.Urlencode, it will encode spaces as '+' rather than %20, is this a known issue or something expected.
6
by: CindyH | last post by:
Hi I'm not sure whether I should send this as a new message or use the one I've been using but... I'm using vb.net 2.0 - My problem is I need to send something like this: 'dim encodedstring =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.